added some code to implement semaphores

This commit is contained in:
hyunghwan.chung
2016-02-18 17:49:56 +00:00
parent fc7a44ba7d
commit 734082db91
6 changed files with 233 additions and 52 deletions

View File

@ -1,3 +1,5 @@
#class Delay(Object)
{
## TODO: support milliseconds or nanoseconds
@ -26,7 +28,7 @@
#class(#pointer) Process(Object)
{
#dcl initial active state prev next sp.
#dcl initial_context runnable_context state prev next sp sem_next.
#method new
{
@ -71,6 +73,27 @@
}
}
#class Semaphore(Object)
{
#dcl count waiting_head waiting_tail.
#method initialize
{
}
#method signal
{
<primitive: #_semaphore_signal>
self primitiveFailed.
}
#method wait
{
<primitive: #_semaphore_wait>
self primitiveFailed.
}
}
#class ProcessScheduler(Object)
{
#dcl tally head tail active.