Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
09-12-2006, 10:20 AM #1
- Join Date
- Jul 2006
- Thanked 0 Times in 0 Posts
How can i handle a situation described bellow
In a particular system there are two threads T1 and T2.
T1 is the master thread that periodically sends messages to the worker thread T2.
The system is time-critical and hence T2 must react to every message that T1 sends.
None of the messages must be lost.T2 performs time consuming operations like
mixing sound samples and sending them to the sound buffer.
Here is the hypothetical POSIX like library that is available to
synchronize the threads:
Mutex locking and unlocking are done through to the calls
int lock(Mutex_t* mutex);
int unlock(Mutex_t* mutex);
Thread messaging is done through condition variables that operate
with an associated mutex.
A thread that responds to a message needs to wait on a condition variable.
It should own the associated mutex prior to entering the wait state.
When it enters the wait state, it simultaneously releases the ownership
of the mutex. Upon return from the wait state, it owns the mutex.
int wait(Condition_t* condition, Mutex_t* mutex);
A thread that sends message to another thread needs to signal the condition
variable. In order to signal the condition variable, the thread must own the
associated mutex.If no thread is waiting on the condition variable, the `signal'
or message is lost. If a thread is waiting on the condition variable, then it resumes
int signal(Condition_t* condition, Mutex_t* mutex);
09-12-2006, 02:02 PM #2
Think about why you would need the methods described in the paper. Read up a bit on them, they are rather common thread methods.
"To iterate is human, to recurse divine." -L. Peter Deutsch