![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
||||
|
||||
Sleep(); //Delay Clarification in multi threaded programmingHello coders,
Before I go any further, I'd like to say that my previous efforts to get clarification have been fruitless. I've referenced books, google etc... Anyways, while I understand that the sleep(some_time) operation is used to delay program execution.... example Specification The program has graphical output as well as console(text) output. The graphical one has 5 threads moving objects across the screen and displays text on the console when the object reaches the end eg "I have reached the wall". Using Semaphores, I can synchronise the output to avoid scrambled text. 1. I don't understand how I can use the sleep(some_time); operation to synchronise processes in addition to using wait(); and signal(); operations to synchronise it any further. Theoretically, I would think the wait(); and signal() ops should be sufficient. 2. Any pointers on how I can identify processes within a multi threaded program that may need the additional sleep(); op. I apologise for not posting any code as I'd like to try and work on it without any influence and as respect to fellow coders. Thanks. |
||||
|
#2
|
||||
|
||||
Re: Sleep(); //Delay Clarification in multi threaded programmingQuote:
Perhaps you may want to take a moment to reflect on some of the terminology used in your post. You're mentioning "synchronise processes" in a (single) multi-threaded program. I think that you mean "threads" and not processes, unless you mean to suggest that each thread is performing some work that you are calling a process. Usually a "process" is a "heavy weight" execution environment that typically has its own protected address space where as a "thread" is a "light weight" execution path that runs in the context of the process' address space and shares memory addresses with the other threads in the process. I recommend reconsidering the terminology so that you get what you want into your post and so that those who may be able to help will better know what it is that you want. It sounds like you want to suspend a thread (or more threads) for some period of time so that you effectively manage thread concurrency in some intended application, which, in your case, is producing some graphical output. With regard to your sleep(some_time) approach, I suspect that you may be struggling with the amount of time. Perhaps you need to identify the "infinite" value for your particular operating system/environment so that the thread is suspended until woken? MxB |
|
#3
|
||||
|
||||
SolvedSorry for the delayed response Bob....
It was simply a matter of understanding the terminology/functions a bit better as you suggested. Thanks, once again |
|
#4
|
||||
|
||||
Re: SolvedQuote:
No worries. Let "us" know if you have any more questions. We definitely want to help and if there is anything that we can do to help get you going where you want, we're ready to participate. MxB |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The