- 1
Use the "pthread_create()" function to generate a new thread that returns an identifier for the thread. An example for code used to call the function is: pthread_create (& ID_for_thread , NULL,function_for_thread , &value ). The id for the thread is stored in ID_for_thread if the function returns successfully. The thread starts execution with function_for_thread.
- 2
Write the "pthread_cancel()" function to cancel the thread before normal return of the thread function. Use the "pthread_detach()" function to detach the thread.
- 3
Call the "pthread_exit()" function to terminate the thread. Use the "pthread_join()" function to suspend the execution of the thread that calls it.
5/6/11
A Tutorial for Unix Threads
A Unix thread utilizes a program counter, register set and stack space. A process can generate multiple threads. Peer threads share data, code and operating system resources. A thread can be terminated more quickly than a process. Threads are also generated faster than processes. When one thread produces data, it can easily be accessed by other threads. A thread uses the address space of the process that generated it. A thread can be terminated by calling a simple routine.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment