H.-H. S. Lee 1 ECE3055 Computer Architecture and Operating Systems Lecture 10 Process, Thread Prof. Hsien-Hsin Sean Lee School of Electrical and Computer.

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
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.
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.
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.
1 From Processes to Threads. 2 Processes, Threads and Processors Hardware can interpret N instruction streams at once  Uniprocessor, N==1  Dual-core,
Chapter 4: Threads. From Processes to Threads 4.3 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th edition, Jan 23, 2005 Threads.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Inter-process Communication Communication in Client-Server.
Chapter 1. Introduction What is an Operating System? Mainframe Systems
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
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.
Lecture 5 Process, Thread and Task September 22, 2015 Kyu Ho Park.
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,
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.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 3 Operating Systems.
CSC 539: Operating Systems Structure and Design Spring 2005
1 OS Review Processes and Threads Chi Zhang
Lecture 4: Processes & Threads. Lecture 4 / Page 2AE4B33OSS Silberschatz, Galvin and Gagne ©2005 Contents The concept of Process Process states and life-cycle.
 Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server.
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.
Lecture 3 Process.
Processes and threads.
Chapter 3: Processes.
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
Process Management Presented By Aditya Gupta Assistant Professor
Processes Overview: Process Concept Process Scheduling
Chapter 3: Process Concept
Chapter 3: Processes Source & Copyright: Operating System Concepts, Silberschatz, Galvin and Gagne.
Chapter 3: Processes.
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.
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix and Windows
EECE.4810/EECE.5730 Operating Systems
EECE.4810/EECE.5730 Operating Systems
Chapter 3: Process Management
Presentation transcript:

H.-H. S. Lee 1 ECE3055 Computer Architecture and Operating Systems Lecture 10 Process, Thread Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Institute of Technology

2 What is an Operating System?  An intermediate program between a user of a computer and the computer hardware (to hide messy details)  Goals: Execute user programs and make solving user problems easier Make the computer system convenient and efficient to use Physical devices Microarchitecture Instruction Set Architecture Operating System CompilerEditors Shell PwrPointSPIM IE 6.1 System Program

3 Computer System Components  Hardware Provides basic computing resources (CPU, memory, I/O)  Operating System Controls and coordinates the use of the hardware among various application programs for various users  Application Programs Define the ways in which the system resources are used to solve the computing problems of users (e.g. database systems, 3D games, business applications)  Users People, machines, other computers

4 Abstract View of System Components User 1 User 2 User 3 User N gccfirefoxemacsmySQL System and application programs Operating System Computer Hardware

5 History of Operating Systems  Vacuum Tubes and Plug boards (1945 – 55) Programmers sign up a time on the signup sheep on the wall  Transistors and batch system (1955 – 65) Mainframes, operated by professional staff Program with punch cards Time wasted while operators walk around A job

6 Time-sharing Systems (Interactive Computing)  The CPU is multiplexed among several jobs that are kept in memory and on disk (The CPU is allocated to a job only if the job is in memory)  A job swapped in and out of memory to the disk  On-line communication between the user and the system is provided When the OS finishes the execution of one command, it seeks the next “control statement” from the user’s keyboard  On-line system must be available for users to access data and code  MIT MULTICS (MULtiplexed Information and Computing Services) Ken Thompson went to Bell Labs and wrote one for a PDP-7 Brian Kernighan jokingly dubbed it UNICS (UNIplexed..) Later spelled to UNIX and moved to PDP-11/20 IEEE POSIX to standardize UNIX

7 Operating System Concepts  Process Management  Main Memory Management  File Management  I/O System Management  Secondary Management  Networking  Protection System  Command-Interpreter System

8 Process Management process  A process is a program in execution  A process contains Address space (e.g. read-only code, global data, heap, stack, etc) PC, $sp Opened file handles  A process needs certain resources, including CPU time, memory, files, and I/O devices OS  The OS is responsible for the following activities for process management Process creation and deletion Process suspension and resumption Provision of mechanisms for:  process synchronization  process communication

9 Process State state  As a process executes, it changes state new new: The process is being created ready ready: The process is waiting to be assigned to a process running running: Instructions are being executed waiting waiting: The process is waiting for some event (e.g. I/O) to occur terminated terminated: The process has finished execution

10 Diagram of Process State

11 Process Control Block (PCB) Information associated with each process  Process state  Program counter  CPU registers (for context switch)  CPU scheduling information (e.g. priority)  Memory-management information (e.g. page table, segment table)  Accounting information (PID, user time, constraint)  I/O status information (list of I/O devices allocated, list of open files etc.)

12 Process Control Block

13 CPU Switch From Process to Process

14 Single and Multithreaded Processes

15 Examples of Threads  A web browser One thread displays images One thread retrieves data from network  A word processor One thread displays graphics One thread reads keystrokes One thread performs spell checking in the background  A web server One thread accepts requests When a request comes in, separate thread is created to service Many threads to support thousands of client requests  RPC or RMI (Java) One thread receives message Message service uses another thread

16 Threads vs. Processes Thread  A thread has no data segment or heap  A thread cannot live on its own, it must live within a process  There can be more than one thread in a process, the first thread calls main and has the process’s stack  Inexpensive creation  Inexpensive context switching  If a thread dies, its stack is reclaimed by the process Processes  A process has code/data/heap and other segments  There must be at least one thread in a process  Threads within a process share code/data/heap, share I/O, but each has its own stack and registers  Expense creation  Expensive context switching  It a process dies, its resources are reclaimed and all threads die

17 Thread Implementation  Process defines address space  Threads share address space  Process Control Block (PCB) contains process-specific info PID, owner, heap pointer, active threads and pointers to thread info  Thread Control Block (TCB) contains thread-specific info Stack pointer, PC, thread state, register … CODE Initialized data Heap Stack – thread 2 Stack – thread 1 DLL’s Reserved Process’s address space $pc $sp State Registers … $pc $sp State Registers … TCB for thread2 TCB for thread1

18 Benefits  Responsiveness When one thread is blocked, your browser still responds E.g. download images while allowing your interaction  Resource Sharing Share the same address space Reduce overhead (e.g. memory)  Economy Creating a new process costs memory and resources E.g. in Solaris, 30 times slower in creating process than thread  Utilization of MP Architectures Threads can be executed in parallel on multiple processors Increase concurrency and throughput

19 Process Creation  Parent process create children processes, which, in turn create other processes, forming a tree of processes  Resource sharing Parent and children share all resources Children share subset of parent’s resources Parent and child share no resources  Execution Parent and children execute concurrently Parent waits until children terminate

20 Processes Tree on a UNIX System

21 Process Creation (Cont.)  Address space Child duplicate of parent Child has a program loaded into it  UNIX examples fork system call creates new process exec system call used after a fork to replace the process’ memory space with a new program

22 C Program Forking Separate Process #include int main(int argc, char *argv[]) { int pid; /* fork another process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { /* child process */ execlp("/bin/ls“,"ls”,NULL); } else { /* parent process */ /* parent will wait for the child to complete */ wait(NULL); printf("Child Complete"); exit(0); }

23 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 If parent is exiting  Some operating system do not allow child to continue if its parent terminates All children terminated - cascading termination