|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| 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
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 |
|
||||
|
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 |
|
|||
|
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. |
|
|||
|
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. |
|
|||
|
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. |
|
|||
|
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. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |