Hi

I wanted to explain

| semaphore p1 p2 |
semaphore := Semaphore new.
p1 := [ semaphore wait.
        'p1' crTrace ] fork.
                
p2 := [semaphore signal.
         'p2' crTrace ] fork.

displays p2 and p1. 
but I would like explain clearly but it depends on the semantics of signal. 


- ==p1== is scheduled and its execution starts to wait on the semaphore, so it 
is removed from the run queue of the scheduler and added to the waiting list of 
the semaphore.
- ==p2== is scheduled and it signals the semaphore. The semaphore takes the 
first waiting process (==p1==) and reschedule it by adding it to the end of the 
suspended lists.


Now this sentence "The semaphore takes the first waiting process (==p1==) and 
reschedule it by adding it to the end of the suspended lists.” is super naive. 
Is the semaphore signalling scheduled? or not?


signal
        "Primitive. Send a signal through the receiver. If one or more 
processes 
        have been suspended trying to receive a signal, allow the first one to 
        proceed. If no process is waiting, remember the excess signal. 
Essential. 
        See Object documentation whatIsAPrimitive."

        <primitive: 85>
        self primitiveFailed

        "self isEmpty    
                ifTrue: [excessSignals := excessSignals+1]    
                ifFalse: [Processor resume: self removeFirstLink]"


I wanted to know what is really happening when a semaphore is signalled. 
Now resume: does not exist on Processor. 

I will look in the VM code. 


S





S.

Reply via email to