Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.

Slides:



Advertisements
Similar presentations
Processes Management.
Advertisements

CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
Processes CSCI 444/544 Operating Systems Fall 2008.
1/27/2010CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying an earlier version.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
CMPT 300: Operating Systems I Ch 3: Processes Dr. Mohamed Hefeeda
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Process Concept An operating system executes a variety of programs
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
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 Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Rensselaer Polytechnic Institute CSCI-4210 – Operating Systems David Goldschmidt, Ph.D.
Implementing Processes and Process Management Brian Bershad.
Exec Function calls Used to begin a processes execution. Accomplished by overwriting process imaged of caller with that of called. Several flavors, use.
Processes: program + execution state
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
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,
11/13/20151 Processes ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original.
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.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
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,
3.1 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Overview: Process Concept Process Scheduling Operations on Processes.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Chapter three.  An operating system executes a variety of programs:  A batch system executes jobs.  A time-shared systems has user programs or tasks.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 8 Processes II Read Ch.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Operating System Components) These components reflect the services made available by the O.S. Process Management Memory Management I/O Device Management.
Chapter 3: Processes.
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
Operating Systems (CS 340 D)
Lecture Topics: 11/1 Processes Process Management
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
Chapter 3: Processes Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Chapter 3: Processes.
Operating Systems (CS 340 D)
Chapter 3: Processes.
CGS 3763 Operating Systems Concepts Spring 2013
Lecture 2: Processes Part 1
Operating Systems Lecture 6.
Process & its States Lecture 5.
Chapter 3: Processes.
Processes Hank Levy 1.
Processes and Process Management
Chapter 3: Processes.
Processes in Unix and Windows
Processes Hank Levy 1.
Presentation transcript:

Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software Engineering University of Wisconsin-Platteville

Outlines process process creation/termination context process control block (PCB) context switch 5-state process model process scheduling short/medium/long term Unix process model

Process Process (also called task, or job) is a program in execution A process includes: Program code (or text) sequence of instructions to be executed note: multiple processes may be running the same code (editor, web-browser, etc) Program counter Stack Data section Context (execution state)

Process Creation One process (parent) can create another process (child) Why: child to do some work for parent Child: identical copy of parent (same code, same data, etc.) Parent: can either wait for the child to complete, or continue executing in parallel (concurrently) with the child parent does not terminate until the child does Unix: Fork() system call creates new process child often uses exec( ) to start another completely different program

Unix Example #include <sys/types.h> #include <stdio.h> To compile on aegis: gcc -o fork fork.c Draw picture below and explain carefully Parent Child a a b b code code pid = fork( ) pid = fork ( ) /* gets pid of 0 */ wait( ) a++ b++ printf /* prints second */ printf /* prints first */ wait( ) = wait until specified process (child here) finishes Understand why only one “before”, two “after”s?? It’s crucial that you understand this! What happens if I replace wait(pid) with “sleep(2)”, sleep 2 seconds child prints its “after” first, probably What happens if I drop the “else” clause? Either one of the two “after”s could happen first — no way to tell What if we want to make sure that one finishes first? Synchronization — next week… #include <sys/types.h> #include <stdio.h> int a = 6; /* global (external) variable */ int main(void) { int b; /* local variable */ pid_t pid; /* process id */ b = 88; printf("before fork\n"); pid = fork(); if (pid == 0) { /* child */ a++; b++; } else /* parent */ wait(pid); printf("after fork, a = %d, b = %d\n", a, b); exit(0); } System call fork() returns the child process ID to the parent and returns 0 to the child process before fork after fork, a = 7, b = 89 after fork, a = 6, b = 88

Process Termination Process executes last statement and asks the operating system to decide it (exit). Output data from child to parent (via wait). Process’ resources are deallocated by operating system. Parent may terminate execution of children processes (abort). Child has exceeded allocated resources. Task assigned to child is no longer required. Parent is exiting. Operating system does not allow child to continue if its parent terminates. Cascading termination.

Context Context – information about running process program code (.text) static data (.bss) heap (dynamic data) procedure call stack - contains temporary data - subroutine parameters, return addresses, local variables register contents general purpose registers program counter (PC) — address of next instruction to be executed stack pointer (SP) program status word (PSW) — interrupt status, condition codes, etc. OS resources in use - open files, connections to other programs accounting information program memory allocation Where do these processes come from? 1. These first two are user processes 2. OS on behalf of user 3. OS daemons (not shown here) How do they end?

Process Control Block (PCB) Information associated with each process Process state Program counter CPU registers CPU scheduling information Memory-management information Accounting information I/O status information

Five State Process Model OS maintains the state of a process New: The process is being created. Running: Instructions are being executed. Waiting (blocked): The process is waiting for some event to occur. Ready: The process ready to run on the CPU. Terminated: The process has finished execution.

Context Switching Context switch : stopping one process and restarting another Sequence of actions: OS takes control (through interrupt) saves old context in the process PCB reloads new context from the new process PCB returns control to app. program

Process Scheduling Queues Process migration between the various queues Job queue – set of all processes in the system Ready queue – set of all processes residing in main memory, ready and waiting to execute Device queues – set of processes waiting for an I/O device

Process Scheduler Long-term scheduler (or job scheduler) Medium-term scheduler Short-term scheduler (or CPU scheduler)

Representation of Process Scheduling

CPU Scheduler Short-term scheduler Selects process from the ready queue to run on the CPU runs when process is created or terminated process switches from running to blocked interrupt occurs Goals minimize response time maximize throughput fairness — share CPU in an equitable fashion efficient use of system resources

Job Scheduler Long-term scheduler selects job from the spool, and loads it into memory runs when A process leaves system Goals good mix of CPU-bound and I/O-bound processes I/O-bound process – spends more time doing I/O than computations, many short CPU bursts CPU-bound process – spends more time doing computations; few very long CPU bursts

Medium-term Scheduler Temporarily swaps processes in/out of main memory may suspend/resume processes goal: balance load for better throughput

Modes of Execution User mode System mode, control mode, or kernel mode Less-privileged mode User programs typically execute in this mode System mode, control mode, or kernel mode More-privileged mode Kernel of the operating system

Execution of the Operating System Non-process Kernel execute kernel outside of any process operating system code is executed as a separate entity that operates in privileged mode Execution Within User Processes operating system software within context of a user process process executes in privileged mode when executing operating system code

Unix State Process Model Unix process states: created - just created not yet ready to run ready (memory) - ready as soon as kernel schedules it ready (disk) - ready, but needs to be swapped to memory asleep - blocked (memory) - waiting on event in memory asleep - blocked (disk) - waiting on event on disk running (kernel) - executing in kernel mode running (user) - executing in user mode zombie - process terminated but left a record for parent to collect