GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 14-Jan-2009, 01:50
panther's Avatar
panther panther is offline
New Member
 
Join Date: Jan 2009
Posts: 2
panther is on a distinguished road

Sleep(); //Delay Clarification in multi threaded programming


Hello 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  
Old 14-Jan-2009, 03:10
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 226
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: Sleep(); //Delay Clarification in multi threaded programming


Quote:
Originally Posted by panther
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.


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  
Old 18-Jan-2009, 11:14
panther's Avatar
panther panther is offline
New Member
 
Join Date: Jan 2009
Posts: 2
panther is on a distinguished road

Solved


Sorry 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  
Old 18-Jan-2009, 14:39
Mexican Bob's Avatar
Mexican Bob Mexican Bob is offline
Member
 
Join Date: Mar 2008
Location: Chicxulub, Yucatán
Posts: 226
Mexican Bob is a jewel in the roughMexican Bob is a jewel in the roughMexican Bob is a jewel in the rough

Re: Solved


Quote:
Originally Posted by panther
Sorry for the delayed response Bob....

It was simply a matter of understanding the terminology/functions a bit better as you suggested.

Thanks, once again

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 GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 00:40.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.