Threading Interview Question
-
Problem 2: Threading: Requirements: 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 say 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 execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete
-
Problem 2: Threading: Requirements: 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 say 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 execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete
are you asking people to answer your interview questions for you ?
-
Problem 2: Threading: Requirements: 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 say 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 execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete
Since you don't have the answer, I take it that you are interviewing for a position ... in which case, answering the question for you does no good for either you nor the company you are applying to work for. Pick up an Intro to Multithreading book, or at the very least try to come up with a solution yourself before asking for help.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
Problem 2: Threading: Requirements: 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 say 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 execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete
If you would have done your homeworks yourself when you were at school, you would be able to answer the interview questions :rolleyes:
Cédric Moonen Software developer
Charting control [Updated - v1.1] -
If you would have done your homeworks yourself when you were at school, you would be able to answer the interview questions :rolleyes:
Cédric Moonen Software developer
Charting control [Updated - v1.1]Cedric Moonen wrote:
If you would have done your homeworks yourself when you were at school, you would be able to answer the interview questions
1 point ! :)
Cedric Moonen wrote:
Charting control [Updated - v1.1]
hum hummm :cool:
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
-
are you asking people to answer your interview questions for you ?
This is not my interview questions. I saw this question somewhere and I wanted to increase my Academic knowledge.
-
Problem 2: Threading: Requirements: 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 say 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 execution. int signal(Condition_t* condition, Mutex_t* mutex); Task: You can write this in pseudo code. The idea is to come up with the best and efficient algorithm that would address the requirements. Search Not Complete
This is not my interview questions. I saw this question somewhere and I wanted to increase my Academic knowledge. Noting related to homework.