... continued ...
-threads:
-threads are subset of processes ie a flow of control within a process.
-threads are the fundamental unit of cpu utilization.
-a process can have one or more threads ie the threads of a process share the same address space in mem.
-threads increase efficiency - a multithreaded process can do multiple things simultaneously.
-eg: a web browser process may have one thread displaying graphics while another gets data from disk.
-a thread can listen for client requests and spawn a new thread for the req; then go back to listening.
-multithreading becomes more efficient on multicore chips.
-in that, each thread can run independently on a different core in parallel.
-note: the os sees each core within a chip as a separate processor.
-most os kernels these days have multiple threads.
-eg: linux has a multithreaded kernel that among other things do free memory management.
-threads exist in both the user and kernel space.
-threads in the user space interact with threads in kernel space via system calls.
-the relationship between threads in user space and kernel space may be many-one, many-many, one-one.
-the one-one model is more common in contemporary os.
-threads are implemented via three main type of libraries.
-the three libraries are:
. pthreads -for linux, unix
. win32 api -for windows world
. java threads -for jvm implementations.
-in linux, the distinction between process and threads is blurry.
-instead they are treated as 'tasks'.
-for this, the clone() system call is used instead of a succession of fork() and exec() calls.
-note: when a child process is created first the fork() call is made.
-this creates two identical address spaces (ie processes).
-thereafter the exec() call is made to load a binary image of a program into memory (ie executes it).
-in this manner, the parent-child processes are able to communicate initially and then go separate ways.
-the parent then runs the wait() system call to wait for a return code from the child after the child finishes its work.
-in linux, the clone() system call creates the tasks.
-the task 'points' to the address space of the parent instead of creating a separate address space for the child.
---xxxxx--
-threads:
-threads are subset of processes ie a flow of control within a process.
-threads are the fundamental unit of cpu utilization.
-a process can have one or more threads ie the threads of a process share the same address space in mem.
-threads increase efficiency - a multithreaded process can do multiple things simultaneously.
-eg: a web browser process may have one thread displaying graphics while another gets data from disk.
-a thread can listen for client requests and spawn a new thread for the req; then go back to listening.
-multithreading becomes more efficient on multicore chips.
-in that, each thread can run independently on a different core in parallel.
-note: the os sees each core within a chip as a separate processor.
-most os kernels these days have multiple threads.
-eg: linux has a multithreaded kernel that among other things do free memory management.
-threads exist in both the user and kernel space.
-threads in the user space interact with threads in kernel space via system calls.
-the relationship between threads in user space and kernel space may be many-one, many-many, one-one.
-the one-one model is more common in contemporary os.
-threads are implemented via three main type of libraries.
-the three libraries are:
. pthreads -for linux, unix
. win32 api -for windows world
. java threads -for jvm implementations.
-in linux, the distinction between process and threads is blurry.
-instead they are treated as 'tasks'.
-for this, the clone() system call is used instead of a succession of fork() and exec() calls.
-note: when a child process is created first the fork() call is made.
-this creates two identical address spaces (ie processes).
-thereafter the exec() call is made to load a binary image of a program into memory (ie executes it).
-in this manner, the parent-child processes are able to communicate initially and then go separate ways.
-the parent then runs the wait() system call to wait for a return code from the child after the child finishes its work.
-in linux, the clone() system call creates the tasks.
-the task 'points' to the address space of the parent instead of creating a separate address space for the child.
---xxxxx--
No comments:
Post a Comment