Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System


Published on

Published in: Education, Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Process, Threads, Symmetric Multiprocessing and Microkernels in Operating System

  1. 1. Student’s Name Matric Number Aniyah binti Amirhussin B031310042 Azwana binti Ahmad B031310071 Daliah binti Daud B031310491 Goh Yu Fern B031310113 Nik Siti Noor Fadhillah binti Md Saad B031310496 Rahilda Nadhirah Norizzaty binti Rahiddin B031310111
  2. 2.  Also known as task.  Execution of an individual program.  Contains program code and its current activity  Can be traced to list the sequence of instructions that execute. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.
  3. 3.  While program is executing, processes are stored in data structure known as PCB.  PCB is created for each process.  The creation and management of PCB is done by OS  PCB has sufficient information. Thus, it’s possible to interrupt a running process and later resume execution as if there is no interruption. Process = Program code + Associated data + PCB
  4. 4. Change to other value, For example: blocked or ready Current values are saved in appropriate fields of corresponding PCB OS is now free to put other process in Running state
  5. 5.  OS program that moves the processor from one process to another.  Prevents a single process from monopolizing processor time.  Decides who goes next according to a scheduling algorithm.  CPU will execute instructions from the dispatcher while switching from process A to process B.
  6. 6. Process Creation * Process (parent) creates another process (child) called as process spawning. * Submission of batch job and user is logs on. * It is created to provide service such as printing. Process Termination * Batch job issues Halt instruction (OS service call for termination) and user is logs off. * Occurs when quitting an application or error and faults condition appear. Reasons for Process Termination * Normal completion * Time limit exceeded * Memory unavailable * Protection error (eg: write to read-only file) * I/O failure
  7. 7. o Process may be in one of two states: running, not running. o Dispatcher cannot select the process that is in the queue the longest because it may be blocked o Solution: split Not Running into two states: i) Ready – prepare to execute when given opportunity ii) Blocked/Waiting – process cannot execute until some event occurs
  8. 8. 3. A Five-State Process Model
  9. 9. 4. Suspended Process  Processor faster than I/O (processes wait for I/O)  Swap these processes to disk to free up memory  Block state -> suspend state, when swap to disk  Two new state - Blocked, suspend: blocked processes which have been swapped out to disk - Ready, suspend: ready processes which have been swapped out to disk
  10. 10. One Suspend State
  11. 11. Two Suspend State
  12. 12. OS have tables for managing processes and resources. 1. Memory tables - Allocation of main and secondary memory to processes - Protection attributes for access to shared memory regions - Information needed to manage virtual memory 2. I/O tables - I/O device is available or assigned - Status of I/O operation - Location in main memory being used as the source or destination of the I/O transfer
  13. 13. 3. File tables - Existence of files - Location on secondary memory - Current Status - Attributes - Sometimes this information is maintained by a file- management system 4. Process tables - Where process is located - Attributes necessary for its management - Process ID - Process state - Location in memory
  14. 14. 1. Modes of Execution i. User Mode * Less-privileged mode * User programs typically execute in this mode ii. System mode, Control mode or Kernel Mode * More-privileged mode * Kernel of the OS
  15. 15. 2. Process Creation  Assign a unique process identifier  Allocate space for the process  Initialize process control block  Set up appropriate linkages Eg: add new process to linked list used for scheduling queue  Create or expand other data structures Eg: maintain an accounting file
  16. 16.  A thread is the smallest unit of processing that can be performed in an OS.  An execution state (running, ready, etc.)  Has an execution stack.  In most modern operating systems, a thread exists within a process - that is, a single process may contain multiple threads.
  17. 17.  On a single processor, multi threading generally occurs by as in multitasking, the processor switches between different threads.  This context switching generally happens frequently enough that the user perceives the threads or tasks to be running at the same time.  On the multiprocessor or mutli-core system, the threads or task actually do run at the same time, with each processor or core running a particular thread or task.
  18. 18. Single and Multithreading Processes
  19. 19. • Multithreading: when OS supports multiple threads of execution within a single process. • Single threading: when the OS does not recognize the concept of thread. • MS-DOS supports a single thread. • UNIX supports multiple user processes but only supports one thread per process • Windows 2000, Solaris, Linux, Mach, and OS/2 support multiple threads
  20. 20. Thread Control Block contains a register image, thread priority and thread state information
  21. 21.  Thread minimize context switching time.  Use of threads provides concurrency within a process.  Efficient communication.  Economy- It is more economical to create and context switch threads.  Utilization of multiprocessor architectures to a greater scale and efficiency.
  22. 22.  Three key states: running, ready, blocked  No suspend state since all threads share the same address space.  Suspending a process involves suspending all threads of the process.  Termination of a process, terminates all threads within the process.  States associated with a change in thread state: i. Spawn -spawn another thread ii. Block iii. Unblock iv. Finish
  23. 23.  Contains code for:
  24. 24. 1. User Level Threads – (user managed thread) Diagram Of User-level Thread o All thread management is done by the application. o The kernel is not aware of the existence of threads. o OS only schedules the process, not the threads within process. o Programmer using a thread library to manage threads (create,delete,schedule)
  25. 25. User-level threads can be implemented on operating system that does not support threads. Implementing user-level threads does not require modification of operating system where everything is managed by the thread library. Simple representation which the thread is represented by a the thread ID, program counter, register, stack , all stored in user process address space. Simple management where creating new threads, switching threads and synchronization between threads can be done without intervention of the kernel. Fast and efficient where switching thread is much more inexpensive compared to a system call. There is a lack of coordination between threads and operating system kernel. A process gets one time slice no matter it has 1 thread or 10000 threads within it. It is up to the thread itself to give up the control to other threads. If one thread made a blocking system call, the entire process can be blocked in the kernel, even if other threads in the same process are in the ready state.
  26. 26. 2. Kernel-Level Threads (OS managed threads acting on kernel, an OS core)  All thread management is done by the kernel.  Kernel maintains context information for the process and the threads.  No thread library but an API to the kernel thread facility.  Switching between threads requires the kernel.  Scheduling is done on a thread basis.
  27. 27. Kernel can simultaneously schedule multiple threads from the same process on multiple processes. If one threads in a process is blocked, the Kernel can schedule another threads of the same process. Kernel routines themselves can multithreaded. Kernel threads are generally slower to create and manage than the user threads. Transfer of control from one thread to another within same process requires a mode switch to the Kernel.
  28. 28. User Level VS Kernel Level Thread User Level Threads Kernel Level Thread Faster to create and manage. Slower to create and manage. Implementation is by a thread library at the user level. OS supports creation of kernel thread. Generic and can run on any OS. Specific to the OS. Multi-threaded application can not take advantage of multiprocessing. Kernel routines themselves can be multithreaded.
  29. 29. 1. Many to One Relationship  Many user-level threads mapped to single kernel threads.
  30. 30. 2. Many to Many Relationship  Allows many user level threads to be mapped to many kernel threads.  Allows the operating system to create a sufficient number of kernel threads.
  31. 31. 2. One to One Relationship  Each user-level thread maps to kernel threads.  Allow another threads to run if block.  Run parallel
  32. 32.  Each CPU has equal access to resources.  Each CPU determines what to run using a standard algorithm.  Kernel can execute on any processor. - Allowing portions of the kernel to execute in parallel.  Typically each processor does self-scheduling from the pool of available process or threads. Proc 1 Proc 2 Proc 3 Proc 4 Mem 1 Mem 2 Mem 3 Mem 4
  33. 33. Symmetric Multiprocessor Organization
  34. 34. 1. Simultaneous concurrent processes or threads 2. Scheduling 3. Synchronization 4. Memory management 5. Reliability and fault tolerance
  35. 35.  From multiple boards on a shared bus to multiple processors inside a single chip.  Caches both 1. Private data are used by a single processor 2. Shared data are used by multiple processors  Caching shared data reduces latency to shared data, memory bandwidth for shared data, and interconnect bandwidth cache coherence problem
  36. 36. ADVANTAGES High reliability Fault tolerant support is straight forward Balanced workload DISADVANTAGES Resources conflicts. Example: memory and I/O Complex implementation
  37. 37.  Involves synchronization of access to global ready queue Eg: only one processor must execute a job at one time  Processors: CPU1, CPU2, CPU3, …  When a processor accesses the ready queue: 1. If they attempt access to the ready queue, all other processors (CPU2, CPU3, …) must wait; denied access. 2. Accessing processor (eg. CPU1) removes a process from ready queue, and dispatch’s process on itself. 3. Just before dispatch, that processor makes ready queue again available for use by the other CPU’s. Synchronization Issues
  38. 38.  This structures the operating system by removing all nonessential portions of the kernel and implementing them as system and user and user level programs.  Provide minimal process and memory management & communication facility  Communication between components if the OS is provided by massage passing
  39. 39. ADVANTAGES Extending the OS becomes much easier. Any changes to the kernel tend to be fewer, since the kernel is smaller. Provides more security and reability MAIN DISADVANTAGES It is poor performance due to increase system overhead from message passing.
  40. 40. Operating systems developed in the mid to late 1950s were designed with little concern about structure.  The problems caused by mutual dependence and interaction were grossly underestimated.  In these monolithic operating systems, virtually any procedure can call any other procedure – the approach Modular programming techniques were needed to handle this scale of software development.  Layered operating systems were developed in which functions are organized hierarchically and interaction only takes place between adjacent layers.  Most or all of the layers execute in kernel mode. PROBLEM: Major changes in one layer can have numerous effects on code in adjacent layers - many difficult to trace. And security is difficult to build in because of the many interactions between adjacent layers.
  41. 41. In a Microkernel - only absolutely essential core OS functions should be in the kernel.  Less essential services and applications are built on the microkernel and execute in user mode.  Common characteristic is that many services that traditionally have been part of the OS are now external subsystems that interact with the kernel and with each other;  These include device drivers, file systems, virtual memory manager, windowing system, and security services. The microkernel functions as a message exchange:  It validates messages,  Passes them between components,  Grants access to hardware. The microkernel also performs a protection function; it prevents message passing unless exchange is allowed.