1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.

Slides:



Advertisements
Similar presentations
Chapter 3 Process Description and Control
Advertisements

Process management Information maintained by OS for process management  process context  process control block OS virtualization of CPU for each process.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
1 Operating Systems and Protection CS Goals of Today’s Lecture How multiple programs can run at once  Processes  Context switching  Process.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
1 Processes Professor Jennifer Rexford
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CS-334: Computer.
Review: Process Management Objective: –Enable fair multi-user, multiprocess computing on limited physical resources –Security and efficiency Process: running.
Introduction to Kernel
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Mehmet Can Vuran, Instructor University of Nebraska-Lincoln Acknowledgement: Overheads adapted from those provided by the authors of the textbook.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Process Description and Control A process is sometimes called a task, it is a program in execution.
System Calls 1.
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.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Introduction to Processes CS Intoduction to Operating Systems.
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.
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
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
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,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Computer Studies (AL) Operating System Process Management - Process.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Operating System Structure A key concept of operating systems is multiprogramming. –Goal of multiprogramming is to efficiently utilize all of the computing.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Processes & Threads Introduction to Operating Systems: Module 5.
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
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.
What is a Process ? A program in execution.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Processes 2 Introduction to Operating Systems: Module 4.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Introduction to Kernel
Processes and threads.
Process concept.
Process Management Process Concept Why only the global variables?
OPERATING SYSTEMS CS3502 Fall 2017
Protection of System Resources
Lecture Topics: 11/1 Processes Process Management
Day 08 Processes.
Day 09 Processes.
Chapter 3: Processes.
Intro to Processes CSSE 332 Operating Systems
Process management Information maintained by OS for process management
Structure of Processes
More examples How many processes does this piece of code create?
System Structure and Process Model
Process & its States Lecture 5.
PROCESS MANAGEMENT Information maintained by OS for process management
Process Description and Control
Lecture Topics: 11/1 General Operating System Concepts Processes
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
Chapter 3: Processes.
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Presentation transcript:

1 Computer Systems II Introduction to Processes

2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent processes)

3 At First … (1945 – 1955) n In the beginning, there really wasn’t an OS -Program binaries were loaded using switches -Interface included blinking lights (cool !)

4 OS Evolution: Step 1 n Very simple OS (1955 – 1965) -Library of common subroutines read, write, etc. -Single programming (one application at a time) n Problem - system expensive, inefficient -Q: What to do while we wait for the I/O device ? -A: Run more processes; when one blocks, switch to another Program P. read. User Program Operating system Free memory!!! system call read begin Start I/O Wait for I/O to complete End I/O end

5 OS Evolution: Step 2 n Multiprogramming (1965 – 1980) -Multiple running processes -When one process (job) blocks, switch to another

6 Multiprogramming Issues n Processes (jobs) share the memory -What if a process starts scribbling in memory? n Processes share the CPU -What if a program has infinite loops?

7 Multiprogramming Issue 1 n Processes (jobs) share the memory -What if a process starts scribbling in memory? n Solution: Protection -A program cannot access memory outside its own space -But what about the operating system? n Solution: Two execution modes -user mode and system (supervisor, monitor) mode -OS executes in system mode, user programs in user mode. -Attempts to execute privileged instructions while in user mode results in a trap (to be discussed later).

8 Multiprogramming Issue 2 n Processes (jobs) share the CPU -What if a program has infinite loops? n Solution: Timer Interrupts -The OS sets the internal clock to generate an interrupt at some specified future time. -This interrupt time is the process quantum. -When the timer interrupt occurs, the CPU switches to another process. This prevents the system being held up by processes in infinite loops.

9 Timer Interrupts n Multiprogramming is also called pseudoparallelism since one has the illusion of a parallel processor. n Different from real parallelism in which two or more processes are actually running at once on two different processors.

10 Timer Interrupts Example n Suppose P1, P2 and P3 are ready to run (in this order). P1 executes for 3 time units, P2 executes for 4 times units, and P3 executes for 2 time units. Neither process invokes I/O. Assuming that a timer interrupt occurs every time unit, fill in the table below: Time (in units)RunningReady to Run   9

11 Processes

12 Recall: Memory Layout of a Process local variables and function parameters global variables instructions (code)

13 Program vs. Process n A process is a program in execution.start main.call DoSomething … global 1 global 2 local 1 local 2 5 Stack Data Text int global1 = 0; int global2 = 0; void DoSomething() { int local2 = 5; local2 = local2 + 1;... } int main() { char local1[10]; DoSomething();... } CPU Registers Program (passive, on disk) Process (active, in memory) Main Memory

14 What if More Processes in Memory? n Each process has its own Code, Data, Heap and Stack OS Free space P0 Free space P1 P2 Code Data Stack

15 Process Creation (1) n Modern general purpose operating systems permit a user to create and destroy processes. n In Unix this is done by the fork system call, which creates a child process, and the exit system call, which terminates the current process.

16 n After a fork, both parent and child keep running, and each can fork off other processes. n A process tree results. The root of the tree is a special process created by the OS during startup. Process Creation (2) n A process can choose to wait for children to terminate. For example, if C issued a wait() system call, it would block until G finished.

17 Bootstrapping n When a computer is switched on or reset, there must be an initial program that gets the system running n This is the bootstrap program -Initialize CPU registers, device controllers, memory -Load the OS into memory -Start the OS running n OS starts the first process (such as “init”) n OS waits for some event to occur -Hardware interrupts or software interrupts (traps)

18 Process States and Transitions

19 Run, Blocked and Ready States n Consider a running process P that issues an I/O request -The process blocks -At some later point, a disk interrupt occurs and the driver detects that P's request is satisfied. -P is unblocked, i.e. is moved from blocked to ready -At some later time the operating system picks P to run n Ready: -Processes not allocated to the CPU, but ready to run n Running: -Process (one!) allocated to the CPU n Blocked: -Processes waiting for some event to occur before ready to run

20 Transitions n Ready – Running: n Running – Ready: n Running – Blocked: n Blocked – Ready: n Suspend and Resume states will be discussed later (In the memory management module.)

21 When to Change the Running Process? n When a process is stalled waiting for I/O -Better utilize the CPU, e.g., while waiting for disk read n When a process has been running for a while -Sharing on a fine time scale to give each process the illusion of running on its own machine -Trade-off efficiency for a finer granularity of fairness CPU I/O 1: CPU I/O 2: CPU I/O 1: CPU I/O 2:

22 State Transition Example n Suppose P2, P3, P4 are in this order in the Ready Queue, and that the following sequence of events occurs: Time 5: P1 invokes read Time 15: P2 invokes write Time 20: Interrupt (P1's read complete) Time 30: P3 terminates. Time 35: Interrupt (P2's write complete) Time 40: P4 terminates Time 45: P1 terminates Assume that processes are always appended at the end of a queue, and the first process in the queue is always scheduled. Fill in the table to show the process states after each event. TimeRunningReadyBlocked 5+  15+  20+  30+  35+  40+  45+ 

23 Switching Between Processes Running Save context Load context Save context Load context RunningBlocked Process 1 Process 2 n Context -State the OS needs to restart a preempted process, stored in the PCB n Context switch -Save the context of current process -Restore the saved context of some previously preempted process -Pass control to this newly restored process

24 Process identifier Process state New, ready, blocked, halted CPU registers I/O status information Open files, I/O requests, … Memory management information Page tables (to be discussed later) CPU scheduling information Priority (to be discussed later) Context: What the OS needs to save Process Control Block (PCB) n most important data structure n read and written by every OS module

25 Context Switching Revisited

26 Summary n Process -Program in execution n Multiprogramming -Processes executing concurrently -Take turns using the CPU n Process States and Transitions -Run, Blocked and Ready -Suspend (on disk) and Resume n Process Control Block -Information associated to each process n Context Switching