Operating System Concepts and Techniques Lecture 3 Process M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed.,

Slides:



Advertisements
Similar presentations
Chapter 3 Process Description and Control
Advertisements

Process Description and Control
Process Description and Control Chapter 3. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Processes CSCI 444/544 Operating Systems Fall 2008.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
CSCE 351: Operating System Kernels
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
BINA RAMAMURTHY UNIVERSITY AT BUFFALO System Structure and Process Model 5/30/2013 Amrita-UB-MSES
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process Description and Control
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Processes Tarek Abdelzaher Vikram Adve.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Introduction to Processes CS Intoduction to Operating Systems.
Today’s Topics Introducing process: the basic mechanism for concurrent programming –Process management related system calls Process creation Process termination.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Chapter 3 Process Description and Control
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Computer Studies (AL) Operating System Process Management - Process.
Operating System Concepts and Techniques Lecture 4 Thread M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First ed.,
Operating Systems Process Creation
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
1 A Seven-State Process Model. 2 CPU Switch From Process to Process Silberschatz, Galvin, and Gagne  1999.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Process Control Management Prepared by: Dhason Operating Systems.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Protection of System Resources
Chapter 3: Processes.
Processes in Unix, Linux, and Windows
Example questions… Can a shell kill itself? Can a shell within a shell kill the parent shell? What happens to background processes when you exit from.
System Structure and Process Model
System Structure and Process Model
Structure of Processes
Processes in Unix, Linux, and Windows
Lecture 2: Processes Part 1
System Structure B. Ramamurthy.
System Structure and Process Model
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process & its States Lecture 5.
Process Description and Control
Process Description and Control
Process Description and Control
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Process Description and Control in Unix
Process Description and Control in Unix
Presentation transcript:

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

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

Some attributes 3 Process identification information Process ID Parent process User identifier Group identifier Process state information Process-visible registers Location counter Condition code flags Stack pointers Process control information Status Priority Process start time CPU time used Children’s CPU time used Scheduling parameters Links Process privileges Memory pointers Devices assigned to the process Open files Flags

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 4

Process table 5 Properties of P 1 blocked Properties of P 2 ready Properties of P 3 blocked Properties of P 4 running Properties of P 5 ready Properties of P 6 ready Properties of P 7 blocked Properties of P 8 ready Properties of P 9 ready Properties of P 10 blocked Process properties State Link Link to PCB Front of ready queue Rear of ready queue

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. 6

Breaking into kernel 7 … call a kernel service from an application program …. Other layers of the operating system A kernel service Kernel Barrier Kernel AB Kernel barrier is busted twice as shown at points A and B 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

Some system calls 8 Process Management pid = fork() pid = waitpid (pid, &static, options) s = execve (name, argv, envp) exit (status) s = kill (pid, sig) pause () wait (&status) alarm (sec) Interprocess Communication qid = msgget(queueid, rights) msgsnd(qid, &mymsg, size, flags) msgrcv(qid, &mymsg, size, type, flags) semid = semget(key, nsems, rights) semop( semid, operation) File System fd = create (name, mode) fd = open (file, how) s = close (fd) n = read (fd, buffer, nbytes) n = write (fp, buffer, nbytes) pos = lseek (fd, offset, whence) s = stat (name, &buf) s = mkdir (path, mode) s = rmdir (path) s = unlink (name) s = chdir (name) s = chmode (name, mode)

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

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

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 11

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? 12

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 13

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); } 14

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 15

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. 16

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?