iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-02-2005, 05:14 AM
WebProWorld Member
 
Join Date: Mar 2005
Posts: 30
abalfazl RepRank 0
Default what is a thread?

Hello
I wanna learn about multithread programming in c or c++.

What is a thread?

I need a simple tutorial,In many programming books about C++,May be it is explained ,But I need a simple tutorial to understand that.

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-02-2005, 05:32 AM
Faglork's Avatar
WebProWorld Veteran
 
Join Date: Feb 2005
Location: Forchheim, Germany
Posts: 936
Faglork RepRank 1
Default

http://tinyurl.com/6wgfe
Reply With Quote
  #3 (permalink)  
Old 03-02-2005, 07:55 AM
WebProWorld Member
 
Join Date: Mar 2005
Posts: 30
abalfazl RepRank 0
Default

Hello


I'm searching about thread ,not c++
Reply With Quote
  #4 (permalink)  
Old 03-02-2005, 08:11 AM
paulhiles's Avatar
WebProWorld 1,000+ Club
 
Join Date: Jul 2003
Location: UK
Posts: 2,089
paulhiles RepRank 0
Default A couple of resources

The link below gives an overview on creating a thread class in C++. I'm not 100% sure if this is what you're after.
http://www.geocities.com/SiliconVall.../dthreads.html

Another useful looking resource is the following page from the O'Reilly site, it provides a link to an introduction and code examples
Win32 Multithreaded Programming

There are lots of search results returned for both "thread" and "C++" remember Google is your friend!

Have a good one!

Paul
Reply With Quote
  #5 (permalink)  
Old 03-02-2005, 09:25 AM
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Cornwall, UK
Posts: 961
speed RepRank 1
Default

If you are using UNIX then this looks quite good, http://www.llnl.gov/computing/tutori...eads/MAIN.html

If nothing else it explains what a thread is.
Reply With Quote
  #6 (permalink)  
Old 03-03-2005, 03:37 PM
WebProWorld Member
 
Join Date: Mar 2005
Posts: 30
abalfazl RepRank 0
Default Mutex

Hello
thanks

Please check this link:

http://www.pandasoftware.com/virus_info/glossary/

Mutex: Some viruses can use a mutex (Mutual Exclusion Object) to control access to resources (e.g. programs or even other viruses) and prevent more than one process from simultaneously accessing the same resource. By doing this, they can make it more difficult for an antivirus to detect them. These viruses can also carry other malicious code in the same way that other types, such as polymorphic viruses, do.




What is a mutex really?

Please give a simple example about mutex.

Why can those viruses make it more difficult for an antivirus to detect them?

Thanks.
Reply With Quote
  #7 (permalink)  
Old 03-03-2005, 03:37 PM
WebProWorld Member
 
Join Date: Mar 2005
Posts: 30
abalfazl RepRank 0
Default Mutex

Hello
thanks

Please check this link:

http://www.pandasoftware.com/virus_info/glossary/

Mutex: Some viruses can use a mutex (Mutual Exclusion Object) to control access to resources (e.g. programs or even other viruses) and prevent more than one process from simultaneously accessing the same resource. By doing this, they can make it more difficult for an antivirus to detect them. These viruses can also carry other malicious code in the same way that other types, such as polymorphic viruses, do.




What is a mutex really?

Please give a simple example about mutex.

Why can those viruses make it more difficult for an antivirus to detect them?

Thanks.
Reply With Quote
  #8 (permalink)  
Old 03-03-2005, 05:08 PM
WebProWorld Veteran
 
Join Date: Aug 2003
Location: Cornwall, UK
Posts: 961
speed RepRank 1
Default

I can't answer the question on Viruses but:

A mutex is an mechanism for stopping multiple threads accessing the same resource at the same time, or for synchronising threads.

For example if you have a printer and 2 threads try to print at the same time your will get a mix of the 2 outputs.

To solve this the threads request lock on the mutex object, ONLY ONE of the threads will be given the lock while the other will be put to sleep until the mutex is released.

We now have one thread running and one sleeping therefore we are guaranteed exclusive access to the printer, and our page prints.

Once the thread has finished with the printer it unlocks the mutex. The act of unlocking will wake the waiting thread(s) one of which will get the lock allowing it to continue with exclusive access to the printer.

I used a printer as an example but in reality you can use mutex objects to protect anything.

A mutex will only allow a single thread to lock it at anyone time, all other threads attempting access will sleep.

The mutex object itself can be thought of, in simple terms, as a memory location with a number it in.

This number starts as 1 when a thread tries to lock the mutex; if the number is 1 it sets it to 0 and continues, if however the number is 0 then the thread blocks (sleeps) waiting for the number to change back to 1.

When a thread no loner needs the mutex and unlocks it it returns the number to a 1 to indicate to the other threads that the mutex is no longer locked.

The other mechanism you need to know about is a semaphore, it is almost identical to a mutex except for the fact that it will allow a predetermined number of threads to lock it simultaneously. If you set this number to 1 then the semaphore acts in the same way as a mutex.

If you go to Google and search on POSIX threads there is a ton of information on all of this with examples, the theory between Windows and UNIX threads is near identical, just the system calls vary.
Reply With Quote
  #9 (permalink)  
Old 03-04-2005, 07:34 AM
WebProWorld Member
 
Join Date: Mar 2005
Posts: 30
abalfazl RepRank 0
Default Thanks

Hello

Thank you very much forn answers
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:38 PM.



Search Engine Optimization by vBSEO 3.3.0