CE01000-3 Operating Systems Lecture 10 Processes and process management in Linux.

Slides:



Advertisements
Similar presentations
1 Processes Professor Jennifer Rexford
Advertisements

1 Processes and Pipes COS 217 Professor Jennifer Rexford.
Processes CSCI 444/544 Operating Systems Fall 2008.
CS 311 – Lecture 14 Outline Process management system calls Introduction System calls  fork()  getpid()  getppid()  wait()  exit() Orphan process.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Process Concept An operating system executes a variety of programs
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Phones OFF Please Processes Parminder Singh Kang Home:
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
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,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
8-Sep Operating Systems Yasir Kiani. 8-Sep Agenda for Today Review of previous lecture Process scheduling concepts Process creation and termination.
CSC 360- Instructor: K. Wu Processes. CSC 360- Instructor: K. Wu Agenda 1.What is a process? 2.Process states 3. PCB 4.Context switching 5.Process scheduling.
Computer Studies (AL) Operating System Process Management - Process.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
System calls for Process management
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Processes Dr. Yingwu Zhu. Process Concept Process – a program in execution – What is not a process? -- program on a disk - a process is an active object,
Operating Systems Process Creation
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Process Management Azzam Mourad COEN 346.
1 A Seven-State Process Model. 2 CPU Switch From Process to Process Silberschatz, Galvin, and Gagne  1999.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 2.
Tutorial 3. In this tutorial we’ll see Fork() and Exec() system calls.
System calls for Process management Process creation, termination, waiting.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
4.1 Operating Systems Lecture 9 Fork and Exec Read Ch
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
A process is a program in execution A running system consists of multiple processes – OS processes Processes started by the OS to do “system things” –
Chapter 3: Processes.
Chapter 3: Process Concept
Chapter 3: Processes.
Processes in Unix, Linux, and Windows
Processes in Unix, Linux, and Windows
Lecture 2: Processes Part 1
Chapter 2: The Linux System Part 2
CS 143A Quiz 1 Solution.
Processes in Unix, Linux, and Windows
System Structure and Process Model
Operating Systems Lecture 6.
Chapter 2: The Linux System Part 3
Chapter 3: Processes.
Chapter 3: Processes.
October 7, 2002 Gary Kimura Lecture #4 October 7, 2002
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
CS510 Operating System Foundations
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
EECE.4810/EECE.5730 Operating Systems
Presentation transcript:

CE Operating Systems Lecture 10 Processes and process management in Linux

Overview of lecture In this lecture we will be looking at : Process creation in Linux and in particular system calls Fork() Exec() Wait() Process scheduling

Process image Reminder - in Linux the process image (organisation of memory for a process) consists of (in a simplified form) Text segment – machine code instructions of program User data segment – initialised data and space for uninitialised data System data segment – all the system data structures for the process

Process creation The only way to create a new process is for an existing process to execute the fork() system call. This call causes the calling process to be duplicated into 2 concurrent processes – a parent process and child process.

Process creation (cont.) The parent and child processes have identical process text (program code) and user data segments and almost identical system data segments - process attributes NOT inherited by the child process from the parent include: process ID (PID) parent process ID (PPID) Accumulated CPU time

Process creation (Cont.) After child process has been spawned both parent and child continue execution with the fork() call returning with a different value depending upon whether the process is the parent or the child process PID of child process returned to parent and 0 to child

fork() example classicfork() { pid_t forkval; if (forkval = fork()) { /* nonzero child PID - parent */ { /* parent code */ } else { /* forkval == 0 - child */ /* child code */ } }

Exec() After a fork() call it is usual to want to run a new program in the child process slot The only way to run a new program is by making an exec() system call The exec() system call replaces text (code) and user data segments of calling process with text and data segments of program file passed as parameter to exec() call

Exec() (Cont.) In addition to a parameter that identifies program file, exec() family of calls requires as parameters the command line switches and parameters i.e. used to form the argv and argc of the program file being exec()ed e.g. execl(“/bin/ls”, “ls”, “-l”, 0);

Waiting Once parent process has set a child running it has 2 possible choices carry on its own execution wait for child to terminate the latter choice uses the wait() system call if there are any child processes running, wait() sleeps until one of them terminates

Waiting (Cont.) wait() returns the terminating process ID and also stores the exit status of the terminating process in the integer variable pointed to by ‘status’ If a parent process terminates before its children then they are adopted by process 1 (init)

Illustration of Process Control Calls

Processes and Threads Linux uses the same internal representation for processes and threads; a thread is simply a new process that happens to share the same address space as its parent. A distinction is only made when a new thread is created by the clone system call.

Processes and Threads (Cont.) fork creates a new process with its own entirely new process context clone creates a new process with its own identity, but that is allowed to share the data structures of its parent Using clone gives an application fine-grained control over exactly what is shared between two threads.

Scheduling in Linux While scheduling is normally thought of as managing the running of processes, in Linux, scheduling also includes the running of various kernel tasks. Running kernel tasks encompasses both tasks that are requested by a running process and tasks that execute internally on behalf of the process.

Scheduling in Linux (Cont.) Linux uses two process-scheduling algorithms: A time-sharing algorithm for fair preemptive scheduling between multiple processes A real-time algorithm for tasks where absolute priorities are more important than fairness

Scheduling in Linux (Cont.) A process’s scheduling class defines which algorithm to apply. For time-sharing processes, Linux uses a prioritized, credit based algorithm. The crediting rule factors in both the process’s history and its priority. This crediting system automatically prioritizes interactive or I/O-bound processes.

Process Scheduling (Cont.) Linux implements the FIFO and round-robin real-time scheduling classes; in both cases, each process has a priority in addition to its scheduling class. The scheduler runs the process with the highest priority; for equal-priority processes, it runs the longest-waiting one

FIFO processes continue to run until they either exit or block A round-robin process will be preempted after a while and moved to the end of the scheduling queue, so that round-robin processes of equal priority automatically time-share between themselves.

References Operating System Concepts. Chapter 22.