int main()
{
static int x = 0;
pthread_t (THREADS);
printf("Initial value of x);
--------
User Level Threads: All thread managment is done by the application. The kernel is
not aware of the existence of threads
Advantage of ULTs: Thread switching does not require kernel, so thread switching
occurs in the threads library / userspace - where there is a scheduler
*Thread switching does not require kernel mode privileges - no context switching
*Scheduling cna be application specific
*ULTs can run on any OS - it's a library so you can use it anywhere
Disadvantage of ULTs
*In a typical OS system calls are blocking
-Ways to overcome, Jacketing: Converts a blocking system call to a non-blocking
system call
------
Message Passing
*Processes that want to exchange data send and recieved messages
*Any message exchange requires
-One send: send(addr, msg, length);
-One recieve: recieve(...);
Advantages
*Very general - sender and recieves can be on different machines
*Relatively secure - reciever can inspect messages it has recieved
Disadvantages
*Hard to use
-Every data transfer requires a send() and a recieve()
-Recieving process must expect the send()
Shared Memory
Two or more processes share a part of their address space
Advantages
Fast and easy to use
Disadvantage
Sender and recievers must be on same machine and less secure