1 / 18

Operating System Concepts and Techniques Lecture 3

Operating System Concepts and Techniques Lecture 3. Process M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011. To order: www.iUniverse.com , www.barnesandnoble.com , or www.amazon.com. Process.

ina
Télécharger la présentation

Operating System Concepts and Techniques Lecture 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Operating System Concepts and Techniques Lecture 3 Process M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed., iUniverse Inc., 2011. To order: www.iUniverse.com, www.barnesandnoble.com, or www.amazon.com

  2. Process • Process: born to run programs • Inside a computer there is a little society of processes; Processes are born, live, and die • Operating system is the governing body of processes • It must keep information about processes, called process attributes, to be able to manage them

  3. Some attributes

  4. Process Control Block (PCB) • Process attributes are kept in an operating system structure called PCB; One for each process • There is one process table in the system • Each row is for one process; it either has all PBC information of the process or some of it and a pointer to the PCB; the latter is our convention • When process is terminated its PCB is removed

  5. Process table Process properties State Link Link to PCB Front of ready queue Rear of ready queue

  6. System calls • Kernel is robust, fault-free, and efficient • It includes numerous useful procedures • Some we can call from application programs, these are called system calls, supervisor calls, or kernel services • Kernel is protected from outside world, entering and leaving is via an strict controlled mechanism.

  7. Breaking into kernel Although a kernel routine is used by an application program, it is like taking a prisoner to an outside hospital for medical services while handcuffed and accompanied by two guards … call a kernel service from an application program …. Other layers of the operating system A B Kernel Barrier A kernel service Kernel Kernel barrier is busted twice as shown at points A and B

  8. Some system calls

  9. The corresponding state in the 3-stae model UNIX States Process birth Created Main memory assigned Not enough main memory Memory shortage swap out Imaginary line Ready to Run in Memory Ready to Run Swapped Preempted Ready Swap in A process is picked to run Sleep condition ended Running obstacle is vanished Back to running Memory needed, swap out Asleep In Memory Sleep Swapped Wait/ Blocked Preempt Needs I/O or circumstance Return User Running Interrupt, Interrupt return Kernel Running Running System call or interrupt Exit, but not disappeared Zombie Unix Process State Transition Model

  10. Why are Processes Created? • Processes are the means of running programs to perform tasks • Processes are created from executable files

  11. When is a Process Created? • At computer start or restart, by OS • Explicit request by a computer user • double clicking on an executable file • opening an executable program file • issuing a command to run a program, etc. • In response to a request from a running process to create a child process

  12. Process creation/termination • Why are processes created? • When is a process created? • What is done to create a process? • What are the tools for creating a process? • What are common in parent and child processes? • What are different between parent and child processes? • How is a process terminated?

  13. What is done to create a process? • Ensure the degree of multiprogramming does not been exceeds its maximum • Generate a unique process ID • Use one row of Process table • Allocate space for the PCB and initialize proper fields; then make the connection between the corresponding row of the process table and this PCB • Allocate space for process context • Allocate space for other preliminary structures such as stacks and stack pointers and initialize the related fields in PCB • Put the process in one of the queues, usually ready queue

  14. Process creation using fork() void main(void) { int pid; int retval; int status; // Pointer to the value returned by the child process pid = fork(); // It is assume that, there is no obstacle in creating // the child process if (pid != 0) // This is the parent process { proc1; // Parent process will continue running procedure proc1 wait (&status); // Wait until the child process is terminated } else { proc2; // Child process will continue running procedure proc2 status = …; // Provide a valid value for the returned status to parent process exit (status); } }

  15. How is a Process Terminated? • When its execution is completed it is logically terminated • For the physical termination of a process, all memory occupied as process images and stacks are first freed. Then, the process control block is freed and the process is removed from the process table • Logical termination of a process takes less processing time than its physical termination. For logical termination it suffices to change the terminating process’s state to terminated and to actually add this process to the set of terminated processes. • It could be killed by OS or user

  16. Summary • Processes are one of the central issues of every operating system • Processes are created to run programs • Process state transition diagram shows the living states of process and its transactions • The request to create a process could come from a user, an application process, or the operating system itself • The same requesters could order the destruction of a process or it could be terminated automatically when its duty is finished or when a fatal fault has occurred • A process that requests the creation of another process becomes the parent process and the created process is called the child process • A child process goes its own way right after it is created • As UNIX is a process-based operating system, this chapter was able to use actual examples from this operating system.

  17. Find out • The purpose of system calls • The purpose of the transitions from kernel to itself • Complete set of Unix system calls • The deficiencies of process • How we can create a child process to run a different program (not a different procedure) • Whether Linux is a process-based operating system or a thread-based one

  18. Any questions?

More Related