SlideShare a Scribd company logo
Operating System Prepared By: Junicel Estomo
What is an Operating System? The 1960’s definition of an operating system is “the software that controls the hardware”.
Objectives of Operating Systems  To hide details of hardware by creating abstraction To allocate resources to processes (Manage resources) Provide a pleasant and effective user interface
One can view Operating Systems from two points of views: Resource manager and Extended machines
History of Operating Systems The 1940's - First Generations The 1950's - Second Generation The 1960's - Third Generation Fourth Generation
System Components Process Management The five major activities of an operating system in regard to process management are: Creation and deletion of user and system processes. Suspension and resumption of processes. A mechanism for process synchronization. A mechanism for process communication. A mechanism for deadlock handling.
Main-Memory Management The major activities of an operating in regard to memory-management are: Keep track of which part of memory are currently being used and by whom. Decide which process are loaded into memory when memory space becomes available. Allocate and deallocate memory space as needed.
File Management A file systems normally organized into directories to ease their use. These directories may contain files and other directions. The five main major activities of an operating system in regard to file management are: The creation and deletion of files. The creation and deletion of directions. The support of primitives for manipulating files and directions. The mapping of files onto secondary storage. The back up of files on stable storage media.
I/O System Management I/O subsystem hides the peculiarities of specific hardware devices from the user. Only the device driver knows the peculiarities of the specific device to whom it is assigned.
Secondary-Storage Management  Generally speaking, systems have several levels of storage, including primary storage, secondary storage and cache storage.  Instructions and data must be placed in primary storage or cache to be referenced by a running program. The three major activities of an operating system in regard to secondary storage management are: Managing the free space available on the secondary-storage device. Allocation of storage space when new files have to be written. Scheduling the requests for memory access
Networking The processors communicate with one another through communication lines called network.  The communication-network design must consider routing and connection strategies, and the problems of contention and security.
Protection System If a computer systems has multiple users and allows the concurrent execution of multiple processes, then the various processes must be protected from one another's activities. Protection refers to mechanism for controlling the access of programs, processes, or users to the resources defined by a computer systems.
Command Interpreter System A command interpreter is an interface of the operating system with the user. There are two main advantages to separating the command interpreter from the kernel. If we want to change the way the command interpreter looks If the command interpreter is a part of the kernel
Chapter 4 Process
The term "process" was first used by the designers of the MULTICS in 1960's. Since then, the term process, used somewhat interchangeably with 'task' or 'job'. The process has been given many definitions for instance A program in Execution. An asynchronous activity. The 'animated sprit' of a procedure in execution. The entity to which processors are assigned. The 'dispatchable' unit.
Process, on the other hand, includes: Current value of Program Counter (PC) Contents of the processors registers Value of the variables The process stack (SP) which typically contains temporary data such as subroutine parameter, return address, and temporary variables. A data section that contains global variables.
A process is the unit of work in a system.
Process State The process state consists of at least following: *  Code for the program. * Program's static data. * Program's dynamic data. * Program's procedure call stack. * Contents of general purpose registers. * Contents of program counter (PC) * Contents of program status word (PSW). * Operating Systems resource in use.
A process goes through a series of discrete process states. New State Running State Blocked (or waiting) State Ready State Terminated state
Process Operations Process Creation System initialization. Execution of a process Creation System calls by a running process. A user request to create a new process. Initialization of a batch job.
A process may create a new process by some create process such as 'fork'. It choose to does so, creating process is called parent process and the created one is called the child processes This creation of process (processes) yields a hierarchical structure of processes like one in the figure.
Following are some reasons for creation of a process User logs on. User starts a program. Operating systems creates process to provide service, e.g., to manage printer. Some program starts another process, e.g., Netscape calls xv to display a picture.
Process Termination The new process terminates the existing process, usually due to following reasons: Normal Exist Fatal Error Killed by another Process
Process States A process goes through a series of discrete process states. New State Terminated State Blocked (waiting) State Running State Ready State
Process State Transitions Following are six(6) possible transitions among above mentioned five (5) states Transition 1 occurs when process discovers that it cannot continue. If running process initiates an I/O operation before its allotted time expires, the running process voluntarily relinquishes the CPU.  Transition 2 occurs when the scheduler decides that the running process has run long enough and it is time to let another process have CPU time. Transition 3 occurs when all other processes have had their share and it is time for the first process to run again
cont... Transition 4 occurs when the external event for which a process was waiting (such as arrival of input) happens. Transition 5 occurs when the process is created. Transition 6 occurs when the process has finished execution.
Process Control Block The PCB contains important information about the specific process including: The current state of the process i.e., whether it is ready, running, waiting, or whatever. Unique identification of the process in order to track "which is which" information. A pointer to parent process. Similarly, a pointer to child process (if it exists). The priority of process (a part of CPU scheduling information). Pointers to locate memory of processes. A register save area. The processor it is running on
Threads Threads Processes Vs Threads Why Threads? User-Level Threads Kernel-Level Threads Advantages of Threads over Multiple Processes Disadvantages of Threads over Multiprocesses Application that Benefits from Threads Application that cannot benefit from Threads Resources used in Thread creation and Process Creation Context Switch Major Steps of Context Switching Action of Kernel to Context switch among threads Action of kernel to Context switch among processes
Threads A thread is a single sequence stream within in a process. a thread of execution is the smallest unit of processing that can be scheduled by an operating system.  Because threads have some of the properties of processes, they are sometimes called lightweight processes, LWP is a specific type of kernel thread that shares the same state and information.
Processes Vs Threads Similarities Like processes threads share CPU and only one thread active (running) at a time. Like processes, threads within a processes, threads within a processes execute sequentially. Like processes, thread can create children. And like process, if one thread is blocked, another thread can run. Differences Unlike processes, threads are not independent of one another. Unlike processes, all threads can access every address in the task . Unlike processes, thread are design to assist one other. Note that processes might or might not assist one another because processes may originate from different users.
Why Threads? Following are some reasons why we use threads in designing operating systems. A process with multiple threads make a great server for example printer server. Because threads can share common data, they do not need to use interprocess communication. Because of the very nature, threads can take advantage of multiprocessors
Cont...  Threads are cheap in the sense that They only need a stack and storage for registers therefore, threads are cheap to create. Threads use very little resources of an operating system in which they are working. That is, threads do not need new address space, global data, program code or operating system resources. Context switching are fast when working with threads. The reason is that we only have to save and/or restore PC, SP and registers.
User-Level Threads User-level threads implement in user-level libraries, rather than via systems calls, so thread switching does not need to call operating system and to cause interrupt to the kernel. In fact, the kernel knows nothing about user-level threads and manages them as if they were single-threaded processes.
Advantages: User-level threads does not require modification to operating systems. Simple Representation: Simple Management: Fast and Efficient
Disadvantages: There is a lack of coordination between threads and operating system kernel. Therefore, process as whole gets one time slice irrespect of whether process has one thread or 1000 threads within. It is up to each thread to relinquish control to other threads. User-level threads requires non-blocking systems call i.e., a multithreaded kernel. Otherwise, entire process will blocked in the kernel, even if there are runable threads left in the processes. For example, if one thread causes a page fault, the process blocks.
 

More Related Content

Os

  • 1. Operating System Prepared By: Junicel Estomo
  • 2. What is an Operating System? The 1960’s definition of an operating system is “the software that controls the hardware”.
  • 3. Objectives of Operating Systems To hide details of hardware by creating abstraction To allocate resources to processes (Manage resources) Provide a pleasant and effective user interface
  • 4. One can view Operating Systems from two points of views: Resource manager and Extended machines
  • 5. History of Operating Systems The 1940's - First Generations The 1950's - Second Generation The 1960's - Third Generation Fourth Generation
  • 6. System Components Process Management The five major activities of an operating system in regard to process management are: Creation and deletion of user and system processes. Suspension and resumption of processes. A mechanism for process synchronization. A mechanism for process communication. A mechanism for deadlock handling.
  • 7. Main-Memory Management The major activities of an operating in regard to memory-management are: Keep track of which part of memory are currently being used and by whom. Decide which process are loaded into memory when memory space becomes available. Allocate and deallocate memory space as needed.
  • 8. File Management A file systems normally organized into directories to ease their use. These directories may contain files and other directions. The five main major activities of an operating system in regard to file management are: The creation and deletion of files. The creation and deletion of directions. The support of primitives for manipulating files and directions. The mapping of files onto secondary storage. The back up of files on stable storage media.
  • 9. I/O System Management I/O subsystem hides the peculiarities of specific hardware devices from the user. Only the device driver knows the peculiarities of the specific device to whom it is assigned.
  • 10. Secondary-Storage Management Generally speaking, systems have several levels of storage, including primary storage, secondary storage and cache storage. Instructions and data must be placed in primary storage or cache to be referenced by a running program. The three major activities of an operating system in regard to secondary storage management are: Managing the free space available on the secondary-storage device. Allocation of storage space when new files have to be written. Scheduling the requests for memory access
  • 11. Networking The processors communicate with one another through communication lines called network. The communication-network design must consider routing and connection strategies, and the problems of contention and security.
  • 12. Protection System If a computer systems has multiple users and allows the concurrent execution of multiple processes, then the various processes must be protected from one another's activities. Protection refers to mechanism for controlling the access of programs, processes, or users to the resources defined by a computer systems.
  • 13. Command Interpreter System A command interpreter is an interface of the operating system with the user. There are two main advantages to separating the command interpreter from the kernel. If we want to change the way the command interpreter looks If the command interpreter is a part of the kernel
  • 15. The term "process" was first used by the designers of the MULTICS in 1960's. Since then, the term process, used somewhat interchangeably with 'task' or 'job'. The process has been given many definitions for instance A program in Execution. An asynchronous activity. The 'animated sprit' of a procedure in execution. The entity to which processors are assigned. The 'dispatchable' unit.
  • 16. Process, on the other hand, includes: Current value of Program Counter (PC) Contents of the processors registers Value of the variables The process stack (SP) which typically contains temporary data such as subroutine parameter, return address, and temporary variables. A data section that contains global variables.
  • 17. A process is the unit of work in a system.
  • 18. Process State The process state consists of at least following: * Code for the program. * Program's static data. * Program's dynamic data. * Program's procedure call stack. * Contents of general purpose registers. * Contents of program counter (PC) * Contents of program status word (PSW). * Operating Systems resource in use.
  • 19. A process goes through a series of discrete process states. New State Running State Blocked (or waiting) State Ready State Terminated state
  • 20. Process Operations Process Creation System initialization. Execution of a process Creation System calls by a running process. A user request to create a new process. Initialization of a batch job.
  • 21. A process may create a new process by some create process such as 'fork'. It choose to does so, creating process is called parent process and the created one is called the child processes This creation of process (processes) yields a hierarchical structure of processes like one in the figure.
  • 22. Following are some reasons for creation of a process User logs on. User starts a program. Operating systems creates process to provide service, e.g., to manage printer. Some program starts another process, e.g., Netscape calls xv to display a picture.
  • 23. Process Termination The new process terminates the existing process, usually due to following reasons: Normal Exist Fatal Error Killed by another Process
  • 24. Process States A process goes through a series of discrete process states. New State Terminated State Blocked (waiting) State Running State Ready State
  • 25. Process State Transitions Following are six(6) possible transitions among above mentioned five (5) states Transition 1 occurs when process discovers that it cannot continue. If running process initiates an I/O operation before its allotted time expires, the running process voluntarily relinquishes the CPU. Transition 2 occurs when the scheduler decides that the running process has run long enough and it is time to let another process have CPU time. Transition 3 occurs when all other processes have had their share and it is time for the first process to run again
  • 26. cont... Transition 4 occurs when the external event for which a process was waiting (such as arrival of input) happens. Transition 5 occurs when the process is created. Transition 6 occurs when the process has finished execution.
  • 27. Process Control Block The PCB contains important information about the specific process including: The current state of the process i.e., whether it is ready, running, waiting, or whatever. Unique identification of the process in order to track "which is which" information. A pointer to parent process. Similarly, a pointer to child process (if it exists). The priority of process (a part of CPU scheduling information). Pointers to locate memory of processes. A register save area. The processor it is running on
  • 28. Threads Threads Processes Vs Threads Why Threads? User-Level Threads Kernel-Level Threads Advantages of Threads over Multiple Processes Disadvantages of Threads over Multiprocesses Application that Benefits from Threads Application that cannot benefit from Threads Resources used in Thread creation and Process Creation Context Switch Major Steps of Context Switching Action of Kernel to Context switch among threads Action of kernel to Context switch among processes
  • 29. Threads A thread is a single sequence stream within in a process. a thread of execution is the smallest unit of processing that can be scheduled by an operating system. Because threads have some of the properties of processes, they are sometimes called lightweight processes, LWP is a specific type of kernel thread that shares the same state and information.
  • 30. Processes Vs Threads Similarities Like processes threads share CPU and only one thread active (running) at a time. Like processes, threads within a processes, threads within a processes execute sequentially. Like processes, thread can create children. And like process, if one thread is blocked, another thread can run. Differences Unlike processes, threads are not independent of one another. Unlike processes, all threads can access every address in the task . Unlike processes, thread are design to assist one other. Note that processes might or might not assist one another because processes may originate from different users.
  • 31. Why Threads? Following are some reasons why we use threads in designing operating systems. A process with multiple threads make a great server for example printer server. Because threads can share common data, they do not need to use interprocess communication. Because of the very nature, threads can take advantage of multiprocessors
  • 32. Cont... Threads are cheap in the sense that They only need a stack and storage for registers therefore, threads are cheap to create. Threads use very little resources of an operating system in which they are working. That is, threads do not need new address space, global data, program code or operating system resources. Context switching are fast when working with threads. The reason is that we only have to save and/or restore PC, SP and registers.
  • 33. User-Level Threads User-level threads implement in user-level libraries, rather than via systems calls, so thread switching does not need to call operating system and to cause interrupt to the kernel. In fact, the kernel knows nothing about user-level threads and manages them as if they were single-threaded processes.
  • 34. Advantages: User-level threads does not require modification to operating systems. Simple Representation: Simple Management: Fast and Efficient
  • 35. Disadvantages: There is a lack of coordination between threads and operating system kernel. Therefore, process as whole gets one time slice irrespect of whether process has one thread or 1000 threads within. It is up to each thread to relinquish control to other threads. User-level threads requires non-blocking systems call i.e., a multithreaded kernel. Otherwise, entire process will blocked in the kernel, even if there are runable threads left in the processes. For example, if one thread causes a page fault, the process blocks.
  • 36.