function A(int a[])
{
SemLock()
//Some Code....
SemUnlock()
}
Suppose some other thread has taken the same lock. Hence this function is blocked. Suppose this function is called by many other threads. All will be blocked. After Unlocking, will the data (parameter a[]) be lost or retained passed in as the parameter by different threads. How does this queuing of data takes place?
parameter a[] is thread specific (non-shareable) so each thread has their own copy of a[]. When a thread created a data-structure for thread is created. a[] is stored in thread's stack.
There is a queue of thread associated with each semaphore variable.
typedef struct {
int count;
queue q; /* queue of threads waiting on this semaphore */
} Semaphore;
[ANSWER]
a[] will not loss.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With