added simple time calculation types/functiosn/macros.

fixed a bug in timed semaphore signalling
This commit is contained in:
hyunghwan.chung
2016-03-24 14:58:47 +00:00
parent 63ce721147
commit 6487143a59
3 changed files with 201 additions and 102 deletions

View File

@ -53,6 +53,15 @@
{
^sp.
}
#method sleep: seconds
{
| s |
s := Semaphore new.
Processor signal: s after: seconds.
## Processor activeProcess dump.
s wait.
}
}
#class Semaphore(Object)
@ -67,6 +76,8 @@
self.fireTimeNsec := 0.
}
## ==================================================================
#method signal
{
<primitive: #_semaphore_signal>
@ -79,6 +90,20 @@
self primitiveFailed.
}
#method waitWithTimeout: seconds
{
<primitive: #_semaphore_wait>
self primitiveFailed
}
#method waitWithTimeout: seconds and: nanoSeconds
{
<primitive: #_semaphore_wait>
self primitiveFailed
}
## ==================================================================
#method heapIndex
{
^heapIndex
@ -302,12 +327,6 @@
^self.active.
}
#method sleep: anInteger
{
<primitive: #_processor_sleep>
self primitiveFailed.
}
#method resume: aProcess
{
<primitive: #_processor_schedule>
@ -329,12 +348,6 @@
"
}
#method remove: aProcess
{
"<primitive: #_processor_remove>"
"TODO: "
}
"
#method yield
{
@ -354,4 +367,17 @@
<primitive: #_processor_add_timed_semaphore>
self primitiveFailed.
}
#method unsignal: aSemaphore
{
<primitive: #_processor_remove_semaphore>
self primitiveFailed.
}
"#method signal: aSemaphore onInput: file
{
}"
"#method signal: aSemaphore onOutput: file
{
}"
}