#include #include #include #include thread First { semaphore* lock; }; thread Second { semaphore* lock; }; void ?{}( First * this, semaphore* lock ) { this->lock = lock; } void ?{}( Second * this, semaphore* lock ) { this->lock = lock; } void main(First* this) { for(int i = 0; i < 10; i++) { sout | "First : Suspend No." | i + 1 | endl; yield(); } V(this->lock); } void main(Second* this) { P(this->lock); for(int i = 0; i < 10; i++) { sout | "Second : Suspend No." | i + 1 | endl; yield(); } } int main(int argc, char* argv[]) { semaphore lock = { 0 }; sout | "User main begin" | endl; { processor p; { First f = { &lock }; Second s = { &lock }; } } sout | "User main end" | endl; }