coroutine.cc.svn-base

来自「德国Erlangen大学教学操作系统源码。」· SVN-BASE 代码 · 共 61 行

SVN-BASE
61
字号
/*****************************************************************************//* Betriebssysteme                                                           *//*---------------------------------------------------------------------------*//*                                                                           *//*                          C O R O U T I N E                                *//*                                                                           *//*---------------------------------------------------------------------------*//* Implementierung des Koroutinenkonzepts.                                   *//* Im Konstruktor wird der initiale Kontext der Koroutine eingerichtet.      *//* Mit go() wird die erste Koroutine aktiviert. Alle weiteren Koroutinen-    *//* wechsel sollten mit resume() erfolgen.                                    *//* Um bei einem Koroutinenwechsel den Kontext sichern zu koennen, enthaelt   *//* jedes Koroutinenobjekt eine Struktur toc, in dem die Werte der nicht-     *//* fluechtigen Register gesichert werden koennen.                            *//*****************************************************************************/#include "guard/guard.h"#include "thread/coroutine.h"#include "machine/toc.h"// Funktionen, die auf der Assembler-Ebene implementiert werden, muessen als// extern "C" deklariert werden, da sie nicht dem Name-Mangeling von C++ // entsprechen.extern "C"{	void toc_settle(struct toc*,void *,void (*) (Coroutine *),void *);	void toc_go(struct toc *);	void toc_switch(struct toc *,struct toc *);}extern void kickoff(Coroutine *object);extern Guard guard; Coroutine::Coroutine (){} Coroutine::Coroutine (void* tos){	toc_settle(&_toc, tos, kickoff, this);}Coroutine::Coroutine (Coroutine &task){}Coroutine::~Coroutine(){}	void Coroutine::go(){	toc_go(&_toc);}void Coroutine::resume(Coroutine& next){	toc_switch(&_toc, &next._toc);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?