NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

Thread Termination
1) Implicit Termination -> When thread routine returns
2) Explicit Termination -> pthread_exit() function
a) When main thread calls pthread_exit() it waits for all other peer threads to terminate, and then terminates the main thread and the entire process with return value of thread_return
3) Some peer thread calls UNIX exit() function which terminates whole process and all the threads associated with that process.
4) Another peer thread terminates the current thread by calling the pthread_cancel() with the ID of the current thread.

Reaping Terminated Threads
1) Threads wait for other peer thread to terminate by calling the pthread_join() function
#include <pthread.h>
int pthread_join(pthread_t tid, void** thread_return) {} Returns 0 if OK, non-zero if error
pthread_join() blocks untill thread with ID tid terminates, assigns the generic void * pointer returned by the thread routine of thread with ID tid to the location pointed by thread_return and then reaps the memory resources(stacks not heap, because heap is shared by all peer threads) held by current threads
2) Difference between UNIX wait() and pthread_join()
-> wait() can be used to wait on any arbitrary child process but no similar pthread_wait() function exists.
-> pthread_join() can only be used to wait on a particular thread

Shared variables in threaded program:
1) Multiple threads can share the same program variables
Each thread has its own separate thread context which includes a thread ID, stack, stack pointer, Register, Program counter, condition codes.
Each thread shares rest of the process context with the other threads. This includes entire user virtual address space, which consists of read-only text(code), read-write data, the heap, library code and data areas.
2) In an operational sense, it is impossible for one thread to read or write the register values of another thread. On the other hand, any thread can access any location in the shared memory. If some thread modifies a memory location then every other thread will eventually see the change if it reads that location.



     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.