Skip to content

Instantly share code, notes, and snippets.

@kunigami

kunigami/system_call.py

Last active Jan 31, 2020
Embed
What would you like to do?
# Excerpt from http://www.dabeaz.com/coroutines/pyos4.py
# coroutine that will be wrapped in a task
def foo():
mytid = yield GetTid()
...
# A system call
class GetTid(SystemCall):
def handle(self):
# The scheduler "injects" task in the
# system call
self.task.sendval = self.task.tid
class Scheduler(object):
...
def mainloop(self):
...
# RHS of foo's yied
result = task.run()
if isinstance(result, SystemCall):
result.task = task
result.sched = self
result.handle()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.