Click here to Skip to main content
15,891,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Ending a Thead and retrieve the result in MFC Pin
Jun Du31-Aug-06 6:56
Jun Du31-Aug-06 6:56 
QuestionOne More IV : Optimization Pin
Nawal K Gupta31-Aug-06 4:39
Nawal K Gupta31-Aug-06 4:39 
AnswerRe: One More IV : Optimization Pin
toxcct31-Aug-06 4:46
toxcct31-Aug-06 4:46 
AnswerRe: One More IV : Optimization Pin
Zac Howland31-Aug-06 4:54
Zac Howland31-Aug-06 4:54 
AnswerRe: One More IV : Optimization Pin
David Crow31-Aug-06 7:30
David Crow31-Aug-06 7:30 
AnswerRe: Clarification Pin
Nawal K Gupta31-Aug-06 19:39
Nawal K Gupta31-Aug-06 19:39 
GeneralRe: Clarification Pin
super_ttd1-Sep-06 23:05
super_ttd1-Sep-06 23:05 
QuestionThreading Interview Question Pin
Nawal K Gupta31-Aug-06 4:37
Nawal K Gupta31-Aug-06 4:37 
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
AnswerRe: Threading Interview Question Pin
Chris Losinger31-Aug-06 4:44
professionalChris Losinger31-Aug-06 4:44 
GeneralRe: Clarification Pin
Nawal K Gupta31-Aug-06 19:37
Nawal K Gupta31-Aug-06 19:37 
AnswerRe: Threading Interview Question Pin
Zac Howland31-Aug-06 4:49
Zac Howland31-Aug-06 4:49 
AnswerRe: Threading Interview Question Pin
Cedric Moonen31-Aug-06 4:53
Cedric Moonen31-Aug-06 4:53 
GeneralRe: Threading Interview Question Pin
toxcct31-Aug-06 5:29
toxcct31-Aug-06 5:29 
AnswerRe: Clarification Pin
Nawal K Gupta31-Aug-06 19:40
Nawal K Gupta31-Aug-06 19:40 
QuestionGenerating GUID Pin
<color>Aljechin 31-Aug-06 4:30
<color>Aljechin 31-Aug-06 4:30 
AnswerRe: Generating GUID Pin
ovidiucucu31-Aug-06 4:52
ovidiucucu31-Aug-06 4:52 
QuestionProblem with select() with multiple sockets [modified] Pin
DevendraC31-Aug-06 4:07
DevendraC31-Aug-06 4:07 
AnswerRe: Problem with select() with multiple sockets Pin
toxcct31-Aug-06 4:17
toxcct31-Aug-06 4:17 
QuestionCAnimateCtrl crashes when going out of scope Pin
almc31-Aug-06 3:46
almc31-Aug-06 3:46 
AnswerRe: CAnimateCtrl crashes when going out of scope Pin
Cedric Moonen31-Aug-06 3:54
Cedric Moonen31-Aug-06 3:54 
GeneralRe: CAnimateCtrl crashes when going out of scope Pin
almc31-Aug-06 3:59
almc31-Aug-06 3:59 
GeneralRe: CAnimateCtrl crashes when going out of scope Pin
David Crow31-Aug-06 7:34
David Crow31-Aug-06 7:34 
GeneralRe: CAnimateCtrl crashes when going out of scope Pin
almc31-Aug-06 23:05
almc31-Aug-06 23:05 
QuestionBackGround Bitmap Pin
radhika2831-Aug-06 3:45
radhika2831-Aug-06 3:45 
AnswerRe: BackGround Bitmap Pin
_AnsHUMAN_ 31-Aug-06 4:03
_AnsHUMAN_ 31-Aug-06 4:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.