Processes and Threads

Size: px
Start display at page:

Download "Processes and Threads"

Transcription

1 Process Processes and Threads A process is an abstraction that represent an executing program A program in execution An instance of a program running on a computer The entity that can be assigned to and executed on a processor A unit of activity characterized by a single sequential thread of execution, a current state, and an associated set of system resources Process Multitasking A process is an abstraction that represent an executing program Code Data Context OS information about the process Running state Process Identifier (PID) I/O operations are much slower than CPU instructions running a single application cause a very low CPU usage Process running Process waiting for I/O A single process running on a CPU

2 Multitasking Multitasking I/O operations are much slower than CPU instructions running a single application cause a very low CPU usage share the CPU among several processes Process management process execution, suspension, resuming Memory management Process 1 Process 2 Process 3 Three processes running on a CPU separate (and protect) data among processes Inter-process communication Inter-process Total CPU usage Process state Process state A process can be: Running A process can be: New Finished for execution, waiting for some event resumed Running suspended I/O completed or unlocked waiting for I/O or just created, no code loaded Running for execution, waiting for some event Finished New resumed Running suspended I/O completed or unlocked waiting for I/O or

3 Process state Process state A process can be: A process can be: New Finished New Finished just created, no code loaded just created, no code loaded Running for execution, waiting for some event Suspended Finished New resumed Suspended Running suspended I/O completed or unlocked waiting for I/O or Running for execution, waiting for some event Suspended Finished New resumed Suspended Running suspended I/O completed or unlocked waiting for I/O or Process state Process creation A process can be: New just created, no code loaded Running for execution but suspended, waiting for some event and suspended Finished Suspend Suspend Dispatch Suspended Activate -out Running Event: I/O completed or unlocked Event New Finished Suspend waiting for I/O or Suspended Activate System initialization background processes (daemons) user interaction processes e.g.: shells Running process request e.g.: user request batch job start External event handling e.g.: client request Unix system call: fork()

4 Unix fork: example Process hierarchy child_id= fork(); /* syscall invocation */ if (child_id == 0) { /* this is the child process */ } else if (child_id > 0) { /* parent process */ PID=500 child_id=501 PID=501 child_id=0 A created process is child of its creator ( parent ) Proc1 } else { /* parent process, but child not created */ Proc2 Proc3 } Proc4 Proc5 Proc6 Process termination Process termination Normal or error exit program auto -termination exit(), abort() Fatal error Unix existing children of a terminated process are inherited by process with PID 1 PID=1 program terminated by OS Killed by another process (through OS) Unix PID=2 PID=5 kill(<target_pid>, SIGTERM) kill(<target_pid>, SIGKILL) PID=22 kill(<target_pid>, <signal>) PID=4

5 Process termination Process scheduling Unix OS keep a queue (or a table) of Process Control Blocks (PCBs) enough information to interrupt and resume a process existing children of a terminated process are inherited by process with PID 1 information on a terminated process are kept in memory (zombies) until its exit code is read by parent (if any) PID=2 PID=1 PID=5 PID=4 PID=22 State: Terminated Exit code: 5 Identifiers Process ID Parent ID User ID Process name Processor state CPU registers CPU flags Stack pointer Program counter Process control information Process state Scheduling information priority reason for blocking Working directory Memory allocation Status of process' open file signals state PCB access Process creation Direct (manipulation of struct fields) fast dangerous many routines access PCB, a single bug can severely hurt the system changes hard to insert many routines have to be updated Through handlers safer 1. Assign ID 2. Allocate memory 3. Initialize PCB 4. Initialize/update control structures scheduling queues, file tables, etc. slow

6 Process scheduling Process scheduling No preemption 1. Run current process until it blocks 2. Save process state, CPU registers, etc. and mark process as blocked 3. Select a ready process (look at priorities) 4. Resume the new process state, CPU registers, etc., and mark process as running when an I/O ends (signaled by an interrupt) mark the blocked process as ready Preemption 1. Run current process until it blocks or its time slice expires 2. Save process state, CPU registers, etc. and mark process as blocked or ready 3. Select a ready process (look at priorities) 4. Resume the new process state, CPU registers, etc., and mark process as running when an I/O ends (signaled by an interrupt) mark the blocked process as ready Process switch Process scheduling slice expiration Example for preemptive OS Syscalls I/O Synchronization Process switch Process 1 overhead Process 2 Process 3 interrupt Process 1 continued Interrupt Error or trap slice has expired Process 2 requires I/O interrupt handling Process 2 marked ready

7 OS execution context Threads Non process kernel Kernel code has its own memory region Process concept applies only to user programs Execution within process Kernel code is executed into the user process context Kernel can use its own stack for interrupts A syscall causes a mode switch, but not a process switch Process based OS Kernel is implemented as a collection of system processes P 1 P 2 P 3 P 4 Kernel P 1 P 2 P 3 P 4 K K K K Proc-switching funcs Components of a process Distinct execution flows in the same address space Distinct stacks and, then, distinct local variables Threads can be suspended and resumed separately Some info are moved from PCB to TCB (thread control block) Kernel and user data are separated Every syscall can cause a process switch Multiprocessor systems can mitigate such an issue P 1 P 2 K 1 K 2 Proc-switching funcs 3 processes 7 threads Threads Threads Management level Kernel level slow switch requires system calls User level in Windows: fibers when a thread is blocked, the whole process is blocked cannot leverage multiprocessor systems only a fiber can be executing at a time explicit user switching SwitchToFiber Hybrid Management level (linux) Kernel level threads are considered as processes sharing the same address space creation clone() syscall use pthread_create

8 Unix threads: example Interprocess communication void *thr_routine(void *arg) { /* entry point for the new thread */ } int shared; /* variable shared among threads */ main() { pthread_t thr; int res; } res = pthread_create(&thr, /* thread pointer */ NULL, /* attribute (NULL for default) */ thr_routine, 0 /* routine argument */ ); if (res) { /* error */ } main thr_routine process threads share global vars threads are distinct on: local variables Signals to signal exceptional events through OS default handling user defined handling Shared memory Message passing fifo (pipe) socket Signals Signals Identified by a numeric identifier a) Caught by a special process routine (if any) signal handler b)handled in default way e.g.: SIGQUIT: program termination c) Ignored d) (within a signal handler) some signals cannot be caught, blocked, or ignored Library OS Application1 kill(1000, SIGUSR1) syscall signal SIGUSR1 Application2 (pid = 1000) signal handler User level Signal handlers are execute asynchronously with respect to the program flow Kernel level SIGKILL, SIGSTOP

9 Shared memory Example: Unix System V shared memory int memid = 0; volatile unsigned char *address; int memid = 0; volatile unsigned char *address; /* create a shared memory area (or get an existing one) */ memid = shmget(1234, /* key */ 1024, /* size */ IPC_CREAT 0600); /* flags */ /* create a shared memory area (or get an existing one) */ memid = shmget(1234, /* key */ 1024, /* size */ IPC_CREAT 0600); /* flags */ Address space Process A Process B Synchronization must be explicitly enforced Address space /* attach (get an address for shared memory) */ address = shmat(memid, NULL, 0); printf("parent: shared memory at address %p\n", address); strcpy((char*)address+10, "Data-String"); printf("parent: string written\n"); address[0] = 0xBA; address[1] = 0xAB; address[2] = 0xAC; address[3] = 0xCA; /* unlock process B */ while (address[0]!= 0x01 address[1]!= 0x02 address[2]!= 0x10 address[3]!= 0x20) ; /* wait for process B */ /* detach */ shmdt((void*)address); /* mark shared memory for removing (when all have been detached) */ shmctl(memid, IPC_RMID, NULL); Process A /* attach (get an address for shared memory) */ address = shmat(memid, NULL, 0); /* address = shmat(memid, (void *)0xc000000, 0); */ printf("child: shared memory at address %p\n", address); while (address[0]!= 0xBA address[1]!= 0xAB address[2]!= 0xAC address[3]!= 0xCA) ; /* wait for process A */ printf("child: string read is: "); printf("\"%s\"\n", address+10); address[0] = 0x01; address[1] = 0x02; address[2] = 0x10; address[3] = 0x20; /* unlock process A */ /* detach */ shmdt((void*)address); Process B int memid = 0; volatile unsigned char *address; Example: Posix shared memory /* create a shared memory area (or get an existing one) */ memid = shm_open("/shm-name", O_RDWR O_CREAT, /* flag */ S_IRUSR S_IWUSR); /* mode */ ftruncate(memid, 1024); /* attach (get an address for shared memory) */ address = mmap(0, /* start */ 1024, /* length */ PROT_READ PROT_WRITE, /* prot */ MAP_SHARED, /* flags */ memid, /* fd */ 0); /* offset */ printf("parent: shared memory at address %p\n", address); strcpy((char*)address+10, "Data-String"); printf("parent: string written\n"); address[0] = 0xBA; address[1] = 0xAB; address[2] = 0xAC; address[3] = 0xCA; /* unlock process B */ while (address[0]!= 0x01 address[1]!= 0x02 address[2]!= 0x10 address[3]!= 0x20) ; /* wait for process B */ /* detach */ munmap((void*)address, 1024); /* mark shared memory for removing (when all have been detached) */ shm_unlink("/shm-name"); Process A int memid = 0; volatile unsigned char *address; /* create a shared memory area (or get an existing one) */ memid = shm_open("/shm-name", O_RDWR O_CREAT, /* flag */ S_IRUSR S_IWUSR); /* mode */ /* attach (get an address for shared memory) */ address = mmap(0, /* start */ 1024, /* length */ PROT_READ PROT_WRITE, /* prot */ MAP_SHARED, /* flags */ memid, /* fd */ 0); /* offset */ /* address = mmap((void )0xc000000, 1024, PROT_READ PROT_WRITE, MAP_SHARED, memid, 0); */ printf("child: shared memory at address %p\n", address); while (address[0]!= 0xBA address[1]!= 0xAB address[2]!= 0xAC address[3]!= 0xCA) ; /* wait for process A */ printf("child: string read is: "); printf("\"%s\"\n", address+10); address[0] = 0x01; address[1] = 0x02; address[2] = 0x10; address[3] = 0x20; /* unlock process A */ /* detach */ munmap((void*)address, 1024); Process B shmget shared memory creation/opening shmat, shmdt attach, detach Unix: see also shmctl control: remove, change permissions, get status shm_open, ftruncate creation/opening, size setting mmap, munmap attach, detach unlink remove

10 Message passing Example: Unix socket Process A send blocking non-blocking receive Process B Synchronization is implicit with the data exchange struct sockaddr_un address; struct sockaddr_un client_addr; int main_socket = -1; int server_socket = -1; socklen_t clientsize; char data[datasize]; /* socket creation */ main_socket = socket( PF_UNIX, SOCK_STREAM, /* reliable, connection-based */ /*SOCK_DGRAM,*/ /* unreliable, connectionless */ 0 /* default protocol */ ); /* assigning an address to socket */ address.sun_family = AF_UNIX; memset(address.sun_path, 0, sizeof(address.sun_path)); strcpy(address.sun_path, "SOCKETNAME"); bind(main_socket, (struct sockaddr*)&address, sizeof(address)); /* put socket in listening mode */ listen(main_socket, 1); clientsize = sizeof(client_addr); /* accept a connection (wait for it) */ server_socket = accept( main_socket, (struct sockaddr*)&client_addr, &clientsize); /* read data */ read(server_socket, data, sizeof(data)); /* write data */ write(server_socket, &i, sizeof(i)); Server side int client_socket = -1; struct sockaddr_un address; char data[datasize]; client_socket = socket( PF_UNIX, SOCK_STREAM, /* reliable, connection-based */ /*SOCK_DGRAM,*/ /* unreliable, connectionless */ 0 /* default protocol */ ); /* assigning an address to socket */ address.sun_family = AF_UNIX; memset(address.sun_path, 0, sizeof(address.sun_path)); strcpy(address.sun_path, "SOCKETNAME"); /* connect to a listening socket */ connect(client_socket, (struct sockaddr*)&address, sizeof(address)); /* write data */ write(client_socket, &i, sizeof(i)); /* read data */ read(client_socket, data, sizeof(data)); Client side Example: IP socket Unix: see also struct sockaddr_in address; struct sockaddr_in client_addr; int main_socket = -1; int server_socket = -1; socklen_t clientsize; /* socket creation */ main_socket = socket(pf_inet, SOCK_STREAM, /* reliable, connection-based (TCP) */ /*SOCK_DGRAM,*/ /* unreliable, connectionless (UDP) */ 0 /* default protocol */ ); /* assigning an address to socket */ address.sin_family = AF_INET; address.sin_port = 3000; inet_aton(" ", &address.sin_addr); bind(main_socket, (struct sockaddr*)&address, sizeof(address)); /* put socket in listening mode */ listen(main_socket, 1); clientsize = sizeof(client_addr); /* accept a connection (wait for it) */ server_socket = accept( main_socket, (struct sockaddr*)&client_addr, &clientsize); res = read(server_socket, data, sizeof(data)); write(server_socket, data, sizeof(data)); Server side int client_socket = -1; struct sockaddr_in address; char data[datasize]; client_socket = socket( PF_INET, SOCK_STREAM, /* reliable, connection-based (TCP) */ /*SOCK_DGRAM,*/ /* unreliable, connectionless (UDP) */ 0 /* default protocol */ ); /* assigning an address to socket */ address.sin_family = AF_INET; address.sin_port = 3000; inet_aton(" ", &address.sin_addr); /* connect to a listening socket */ connect(client_socket, (struct sockaddr*)&address, sizeof(address)); write(client_socket, data, sizeof(data)); read(client_socket, data, sizeof(data)); Client side socket open a new socket (choose domain, and type) bind, listen, accept assign name, start listening, accept incoming connections connect connect to a listening socket write, send, sendto, sendmsg send data read read data

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2.

PROCESS CONCEPTS. Process Concept Relationship to a Program What is a Process? Process Lifecycle Process Management Inter-Process Communication 2. [03] PROCESSES 1. 1 OUTLINE Process Concept Relationship to a Program What is a Process? Process Lifecycle Creation Termination Blocking Process Management Process Control Blocks Context Switching Threads

More information

Processes COMPSCI 386

Processes COMPSCI 386 Processes COMPSCI 386 Elements of a Process A process is a program in execution. Distinct processes may be created from the same program, but they are separate execution sequences. call stack heap STACK

More information

Processes. OS Structure. OS Structure. Modes of Execution. Typical Functions of an OS Kernel. Non-Kernel OS. COMP755 Advanced Operating Systems

Processes. OS Structure. OS Structure. Modes of Execution. Typical Functions of an OS Kernel. Non-Kernel OS. COMP755 Advanced Operating Systems OS Structure Processes COMP755 Advanced Operating Systems An OS has many parts. The Kernel is the core of the OS. It controls the execution of the system. Many OS features run outside of the kernel, such

More information

SMD149 - Operating Systems

SMD149 - Operating Systems SMD149 - Operating Systems Roland Parviainen November 3, 2005 1 / 45 Outline Overview 2 / 45 Process (tasks) are necessary for concurrency Instance of a program in execution Next invocation of the program

More information

Signal Example 1. Signal Example 2

Signal Example 1. Signal Example 2 Signal Example 1 #include #include void ctrl_c_handler(int tmp) { printf("you typed CTL-C, but I don't want to die!\n"); int main(int argc, char* argv[]) { long i; signal(sigint, ctrl_c_handler);

More information

CS510 Operating System Foundations. Jonathan Walpole

CS510 Operating System Foundations. Jonathan Walpole CS510 Operating System Foundations Jonathan Walpole The Process Concept 2 The Process Concept Process a program in execution Program - description of how to perform an activity instructions and static

More information

Process. Program Vs. process. During execution, the process may be in one of the following states

Process. Program Vs. process. During execution, the process may be in one of the following states What is a process? What is process scheduling? What are the common operations on processes? How to conduct process-level communication? How to conduct client-server communication? Process is a program

More information

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7

THE PROCESS ABSTRACTION. CS124 Operating Systems Winter , Lecture 7 THE PROCESS ABSTRACTION CS124 Operating Systems Winter 2015-2016, Lecture 7 2 The Process Abstraction Most modern OSes include the notion of a process Term is short for a sequential process Frequently

More information

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D) MANAGEMENT OF APPLICATION EXECUTION PROCESS CONTROL BLOCK Resources (processor, I/O devices, etc.) are made available to multiple applications The processor in particular is switched among multiple applications

More information

Shared Memory Memory mapped files

Shared Memory Memory mapped files Shared Memory Memory mapped files 1 Shared Memory Introduction Creating a Shared Memory Segment Shared Memory Control Shared Memory Operations Using a File as Shared Memory 2 Introduction Shared memory

More information

Killing Zombies, Working, Sleeping, and Spawning Children

Killing Zombies, Working, Sleeping, and Spawning Children Killing Zombies, Working, Sleeping, and Spawning Children CS 333 Prof. Karavanic (c) 2015 Karen L. Karavanic 1 The Process Model The OS loads program code and starts each job. Then it cleans up afterwards,

More information

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo

PROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo PROCESS MANAGEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

Shared Memory. By Oren Kalinsky

Shared Memory. By Oren Kalinsky Shared Memory By Oren Kalinsky 1 Overview Shared memory (SHM) - two or more processes can share a given region of memory A form of Inter Process Communication (IPC) Other IPC methods pipes, message queues

More information

Memory management. Single process. Multiple processes. How to: All memory assigned to the process Addresses defined at compile time

Memory management. Single process. Multiple processes. How to: All memory assigned to the process Addresses defined at compile time Memory management Single process All memory assigned to the process Addresses defined at compile time Multiple processes. How to: assign memory manage addresses? manage relocation? manage program grow?

More information

* What are the different states for a task in an OS?

* What are the different states for a task in an OS? * Kernel, Services, Libraries, Application: define the 4 terms, and their roles. The kernel is a computer program that manages input/output requests from software, and translates them into data processing

More information

Processes. CS3026 Operating Systems Lecture 05

Processes. CS3026 Operating Systems Lecture 05 Processes CS3026 Operating Systems Lecture 05 Dispatcher Admit Ready Queue Dispatch Processor Release Timeout or Yield Event Occurs Blocked Queue Event Wait Implementation: Using one Ready and one Blocked

More information

Processes and Threads

Processes and Threads TDDI04 Concurrent Programming, Operating Systems, and Real-time Operating Systems Processes and Threads [SGG7] Chapters 3 and 4 Copyright Notice: The lecture notes are mainly based on Silberschatz s, Galvin

More information

Chapter 3: Process Concept

Chapter 3: Process Concept Chapter 3: Process Concept Chapter 3: Process Concept Process Concept Process Scheduling Operations on Processes Inter-Process Communication (IPC) Communication in Client-Server Systems Objectives 3.2

More information

Chapter 3: Process Concept

Chapter 3: Process Concept Chapter 3: Process Concept Chapter 3: Process Concept Process Concept Process Scheduling Operations on Processes Inter-Process Communication (IPC) Communication in Client-Server Systems Objectives 3.2

More information

CS 345 Operating Systems. Tutorial 2: Treasure Room Simulation Threads, Shared Memory, Synchronization

CS 345 Operating Systems. Tutorial 2: Treasure Room Simulation Threads, Shared Memory, Synchronization CS 345 Operating Systems Tutorial 2: Treasure Room Simulation Threads, Shared Memory, Synchronization Assignment 2 We have a treasure room, Team A and Team B. Treasure room has N coins inside. Each team

More information

Processes. Dr. Yingwu Zhu

Processes. Dr. Yingwu Zhu Processes Dr. Yingwu Zhu Process Growing Memory Stack expands automatically Data area (heap) can grow via a system call that requests more memory - malloc() in c/c++ Entering the kernel (mode) Hardware

More information

CHAPTER 3 - PROCESS CONCEPT

CHAPTER 3 - PROCESS CONCEPT CHAPTER 3 - PROCESS CONCEPT 1 OBJECTIVES Introduce a process a program in execution basis of all computation Describe features of processes: scheduling, creation, termination, communication Explore interprocess

More information

Getting to know you. Anatomy of a Process. Processes. Of Programs and Processes

Getting to know you. Anatomy of a Process. Processes. Of Programs and Processes Getting to know you Processes A process is an abstraction that supports running programs A sequential stream of execution in its own address space A process is NOT the same as a program! So, two parts

More information

Chapter 3: Process Concept

Chapter 3: Process Concept Chapter 3: Process Concept Silberschatz, Galvin and Gagne 2013! Chapter 3: Process Concept Process Concept" Process Scheduling" Operations on Processes" Inter-Process Communication (IPC)" Communication

More information

Inter-Process Communication. Disclaimer: some slides are adopted from the book authors slides with permission 1

Inter-Process Communication. Disclaimer: some slides are adopted from the book authors slides with permission 1 Inter-Process Communication Disclaimer: some slides are adopted from the book authors slides with permission 1 Today Inter-Process Communication (IPC) What is it? What IPC mechanisms are available? 2 Inter-Process

More information

ECE 650 Systems Programming & Engineering. Spring 2018

ECE 650 Systems Programming & Engineering. Spring 2018 ECE 650 Systems Programming & Engineering Spring 2018 Inter-process Communication (IPC) Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Recall Process vs. Thread A process is

More information

ECE 650 Systems Programming & Engineering. Spring 2018

ECE 650 Systems Programming & Engineering. Spring 2018 ECE 650 Systems Programming & Engineering Spring 2018 User Space / Kernel Interaction Tyler Bletsch Duke University Slides are adapted from Brian Rogers (Duke) Operating System Services User and other

More information

Chap 4, 5: Process. Dongkun Shin, SKKU

Chap 4, 5: Process. Dongkun Shin, SKKU Chap 4, 5: Process 1 Process Concept Job A bundle of program and data to be executed An entity before submission for execution Process (= running program) An entity that is registered to kernel for execution

More information

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Processes in Unix, Linux, and Windows Unix pre-empted

More information

Major Requirements of an OS

Major Requirements of an OS Process CSCE 351: Operating System Kernels Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization while providing reasonable response time Allocate

More information

3.1 Introduction. Computers perform operations concurrently

3.1 Introduction. Computers perform operations concurrently PROCESS CONCEPTS 1 3.1 Introduction Computers perform operations concurrently For example, compiling a program, sending a file to a printer, rendering a Web page, playing music and receiving e-mail Processes

More information

Chapter 3: Processes. Operating System Concepts 9 th Edition

Chapter 3: Processes. Operating System Concepts 9 th Edition Chapter 3: Processes Silberschatz, Galvin and Gagne 2013 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017 CS 471 Operating Systems Yue Cheng George Mason University Fall 2017 Outline o Process concept o Process creation o Process states and scheduling o Preemption and context switch o Inter-process communication

More information

COSC243 Part 2: Operating Systems

COSC243 Part 2: Operating Systems COSC243 Part 2: Operating Systems Lecture 16: Threads and data sharing Zhiyi Huang Dept. of Computer Science, University of Otago Zhiyi Huang (Otago) COSC243 Lecture 16 1 / 24 Overview Last lecture: Hierarchical

More information

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated? Processes Process Management Chapter 3 1 A process is a program in a state of execution (created but not terminated) Program is a passive entity one on your disk (survivor.class, kelly.out, ) Process is

More information

W4118 Operating Systems. Junfeng Yang

W4118 Operating Systems. Junfeng Yang W4118 Operating Systems Junfeng Yang What is a process? Outline Process dispatching Common process operations Inter-process Communication What is a process Program in execution virtual CPU Process: an

More information

IT 540 Operating Systems ECE519 Advanced Operating Systems

IT 540 Operating Systems ECE519 Advanced Operating Systems IT 540 Operating Systems ECE519 Advanced Operating Systems Prof. Dr. Hasan Hüseyin BALIK (3 rd Week) (Advanced) Operating Systems 3. Process Description and Control 3. Outline What Is a Process? Process

More information

Announcement. Exercise #2 will be out today. Due date is next Monday

Announcement. Exercise #2 will be out today. Due date is next Monday Announcement Exercise #2 will be out today Due date is next Monday Major OS Developments 2 Evolution of Operating Systems Generations include: Serial Processing Simple Batch Systems Multiprogrammed Batch

More information

CSC 539: Operating Systems Structure and Design. Spring 2006

CSC 539: Operating Systems Structure and Design. Spring 2006 CSC 539: Operating Systems Structure and Design Spring 2006 Processes and threads process concept process scheduling: state, PCB, process queues, schedulers process operations: create, terminate, wait,

More information

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476

CSE 451: Operating Systems Winter Module 4 Processes. Mark Zbikowski Allen Center 476 CSE 451: Operating Systems Winter 2015 Module 4 Processes Mark Zbikowski mzbik@cs.washington.edu Allen Center 476 2013 Gribble, Lazowska, Levy, Zahorjan Process management This module begins a series of

More information

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University

COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process. Zhi Wang Florida State University COP 4610: Introduction to Operating Systems (Spring 2014) Chapter 3: Process Zhi Wang Florida State University Contents Process concept Process scheduling Operations on processes Inter-process communication

More information

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009

Roadmap. Tevfik Ko!ar. CSC Operating Systems Fall Lecture - III Processes. Louisiana State University. Processes. September 1 st, 2009 CSC 4103 - Operating Systems Fall 2009 Lecture - III Processes Tevfik Ko!ar Louisiana State University September 1 st, 2009 1 Roadmap Processes Basic Concepts Process Creation Process Termination Context

More information

Design Overview of the FreeBSD Kernel CIS 657

Design Overview of the FreeBSD Kernel CIS 657 Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler (2%

More information

Processes. Process Concept

Processes. Process Concept Processes These slides are created by Dr. Huang of George Mason University. Students registered in Dr. Huang s courses at GMU can make a single machine readable copy and print a single copy of each slide

More information

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University EECS3221.3 Operating System Fundamentals No.2 Process Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University How OS manages CPU usage? How CPU is used? Users use CPU to run

More information

Process. Discussion session 3 1/30/2016

Process. Discussion session 3 1/30/2016 Process Discussion session 3 1/30/2016 A program in execution What is the process? An instance of a program running on a computer The entity can be assigned to and executed on a processor A unit of activity

More information

Process. Prepared by Prof. Hui Jiang Dept. of EECS, York Univ. 1. Process in Memory (I) PROCESS. Process. How OS manages CPU usage? No.

Process. Prepared by Prof. Hui Jiang Dept. of EECS, York Univ. 1. Process in Memory (I) PROCESS. Process. How OS manages CPU usage? No. EECS3221.3 Operating System Fundamentals No.2 Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University How OS manages CPU usage? How CPU is used? Users use CPU to run programs

More information

Processes & Threads. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! More of the same J

Processes & Threads. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! More of the same J Processes & Threads Today! Process concept! Process model! Implementing processes! Multiprocessing once again Next Time! More of the same J The process model! Most computers can do more than one thing

More information

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission 1 Process Heechul Yun Disclaimer: some slides are adopted from the book authors slides with permission 1 Recap OS services Resource (CPU, memory) allocation, filesystem, communication, protection, security,

More information

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms Interprocess Communication 1 Interprocess Communication Mechanisms shared storage shared virtual memory shared files message-based sockets pipes signals Interprocess Communication 2 Message Passing Indirect

More information

Interprocess Communication Mechanisms

Interprocess Communication Mechanisms Interprocess Communication 1 Interprocess Communication Mechanisms shared storage shared virtual memory shared files message-based sockets pipes signals... Interprocess Communication 2 Message Passing

More information

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey

Process Concepts. CSC400 - Operating Systems. 3. Process Concepts. J. Sumey CSC400 - Operating Systems 3. Process Concepts J. Sumey Overview Concurrency Processes & Process States Process Accounting Interrupts & Interrupt Processing Interprocess Communication CSC400 - Process

More information

CS 261 Fall Mike Lam, Professor. Exceptional Control Flow and Processes

CS 261 Fall Mike Lam, Professor. Exceptional Control Flow and Processes CS 261 Fall 2017 Mike Lam, Professor Exceptional Control Flow and Processes Exceptional control flow Most control flow is sequential However, we have seen violations of this rule Exceptional control flow

More information

Linux Operating System

Linux Operating System Linux Operating System Dept. of Computer Science & Engineering 1 History Linux is a modern, free operating system based on UNIX standards. First developed as a small but self-contained kernel in 1991 by

More information

Chapter 3: Processes

Chapter 3: Processes Operating Systems Chapter 3: Processes Silberschatz, Galvin and Gagne 2009 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication (IPC) Examples of IPC

More information

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized)

Process management. What s in a process? What is a process? The OS s process namespace. A process s address space (idealized) Process management CSE 451: Operating Systems Spring 2012 Module 4 Processes Ed Lazowska lazowska@cs.washington.edu Allen Center 570 This module begins a series of topics on processes, threads, and synchronization

More information

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length)

Memory-Mapped Files. generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) File Systems 38 Memory-Mapped Files generic interface: vaddr mmap(file descriptor,fileoffset,length) munmap(vaddr,length) mmap call returns the virtual address to which the file is mapped munmap call unmaps

More information

OPERATING SYSTEMS: Lesson 4: Process Scheduling

OPERATING SYSTEMS: Lesson 4: Process Scheduling OPERATING SYSTEMS: Lesson 4: Process Scheduling Jesús Carretero Pérez David Expósito Singh José Daniel García Sánchez Francisco Javier García Blas Florin Isaila 1 Content Process creation. Process termination.

More information

System Calls and Signals: Communication with the OS. System Call. strace./hello. Kernel. Context Switch

System Calls and Signals: Communication with the OS. System Call. strace./hello. Kernel. Context Switch System Calls and Signals: Communication with the OS Jonathan Misurda jmisurda@cs.pitt.edu System Call An operation (function) that an OS provides for running applications to use CS 1550 2077 strace./hello

More information

Operating Systems & Concurrency: Process Concepts

Operating Systems & Concurrency: Process Concepts Operating Systems & Concurrency: Process Concepts Michael Brockway October 6, 2011 Outline Processes - context, data area, states Process creation, termination unix examples Processes and threads Processes

More information

Inter-process communication (IPC)

Inter-process communication (IPC) Inter-process communication (IPC) Operating Systems Kartik Gopalan References Chapter 5 of OSTEP book. Unix man pages Advanced Programming in Unix Environment by Richard Stevens http://www.kohala.com/start/apue.html

More information

System Call. Preview. System Call. System Call. System Call 9/7/2018

System Call. Preview. System Call. System Call. System Call 9/7/2018 Preview Operating System Structure Monolithic Layered System Microkernel Virtual Machine Process Management Process Models Process Creation Process Termination Process State Process Implementation Operating

More information

Chapter 3: Processes. Operating System Concepts 8 th Edition,

Chapter 3: Processes. Operating System Concepts 8 th Edition, Chapter 3: Processes, Silberschatz, Galvin and Gagne 2009 Outline Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server

More information

Chapter 3: Processes. Operating System Concepts Essentials 8 th Edition

Chapter 3: Processes. Operating System Concepts Essentials 8 th Edition Chapter 3: Processes Silberschatz, Galvin and Gagne 2011 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication

More information

CS307 Operating Systems Processes

CS307 Operating Systems Processes CS307 Processes Fan Wu Department of Computer Science and Engineering Shanghai Jiao Tong University Spring 2018 Process Concept Process a program in execution An operating system executes a variety of

More information

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State

Processes. Process Concept. The Process. The Process (Cont.) Process Control Block (PCB) Process State CS307 Process Concept Process a program in execution Processes An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks All these activities are

More information

Operating System Structure

Operating System Structure Operating System Structure CSCI 4061 Introduction to Operating Systems Applications Instructor: Abhishek Chandra Operating System Hardware 2 Questions Operating System Structure How does the OS manage

More information

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song CSCE 313 Introduction to Computer Systems Instructor: Dezhen Song Programs, Processes, and Threads Programs and Processes Threads Programs, Processes, and Threads Programs and Processes Threads Processes

More information

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals What Is A Process? A process is a program in execution. Process Fundamentals #include int main(int argc, char*argv[]) { int v; printf( hello world\n ); scanf( %d, &v); return 0; Program test

More information

CSCE 313: Intro to Computer Systems

CSCE 313: Intro to Computer Systems CSCE 313 Introduction to Computer Systems Instructor: Dr. Guofei Gu http://courses.cse.tamu.edu/guofei/csce313/ Programs, Processes, and Threads Programs and Processes Threads 1 Programs, Processes, and

More information

! The Process Control Block (PCB) " is included in the context,

! The Process Control Block (PCB)  is included in the context, CSE 421/521 - Operating Systems Fall 2012 Lecture - III Processes Tevfik Koşar Roadmap Processes Basic Concepts Process Creation Process Termination Context Switching Process Queues Process Scheduling

More information

UNIT -3 PROCESS AND OPERATING SYSTEMS 2marks 1. Define Process? Process is a computational unit that processes on a CPU under the control of a scheduling kernel of an OS. It has a process structure, called

More information

Mon Sep 17, 2007 Lecture 3: Process Management

Mon Sep 17, 2007 Lecture 3: Process Management Mon Sep 17, 2007 Lecture 3: Process Management September 19, 2007 1 Review OS mediates between hardware and user software QUIZ: Q: Name three layers of a computer system where the OS is one of these layers.

More information

Processes and Non-Preemptive Scheduling. Otto J. Anshus

Processes and Non-Preemptive Scheduling. Otto J. Anshus Processes and Non-Preemptive Scheduling Otto J. Anshus Threads Processes Processes Kernel An aside on concurrency Timing and sequence of events are key concurrency issues We will study classical OS concurrency

More information

VEOS high level design. Revision 2.1 NEC

VEOS high level design. Revision 2.1 NEC high level design Revision 2.1 NEC Table of contents About this document What is Components Process management Memory management System call Signal User mode DMA and communication register Feature list

More information

Processes. Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively.

Processes. Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively. Processes Process Scheduling, Process Synchronization, and Deadlock will be discussed further in Chapters 5, 6, and 7, respectively. 1. Process Concept 1.1 What is a Process? A process is a program in

More information

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent?

Design Overview of the FreeBSD Kernel. Organization of the Kernel. What Code is Machine Independent? Design Overview of the FreeBSD Kernel CIS 657 Organization of the Kernel Machine-independent 86% of the kernel (80% in 4.4BSD) C C code Machine-dependent 14% of kernel Only 0.6% of kernel in assembler

More information

CSE 380 Computer Operating Systems. Instructor: Insup Lee. University of Pennsylvania Fall 2003

CSE 380 Computer Operating Systems. Instructor: Insup Lee. University of Pennsylvania Fall 2003 CSE 380 Computer Operating Systems Instructor: Insup Lee University of Pennsylvania Fall 2003 Lecture Note 2: Processes and Threads Lecture Note 2.1: Processes and System Calls 1 Process q Consider a simple

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 The Process Concept 2 The Process Concept Process a program in execution

More information

Interprocess Communication

Interprocess Communication Interprocess Communication Reading: Silberschatz chapter 4 Additional Reading: Stallings chapter 6 EEL 358 1 Outline Introduction Shared memory systems POSIX shared memory Message passing systems Direct

More information

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534

CSE 410: Computer Systems Spring Processes. John Zahorjan Allen Center 534 CSE 410: Computer Systems Spring 2018 Processes John Zahorjan zahorjan@cs.washington.edu Allen Center 534 1. What is a process? Processes 2. What's the process namespace? 3. How are processes represented

More information

COMP 3100 Operating Systems

COMP 3100 Operating Systems Programming Interface» A process is an instance of a running program. COMP 3100 Operating Systems» Functionality that an OS provides to applications» Process Management» Input/Output Week 3 Processes and

More information

Chapter 4 Multithreaded Programming

Chapter 4 Multithreaded Programming Chapter 4 Multithreaded Programming Da-Wei Chang CSIE.NCKU Source: Abraham Silberschatz, Peter B. Galvin, and Greg Gagne, "Operating System Concepts", 9th Edition, Wiley. 1 1 Outline Overview Multithreading

More information

Process and Its Image An operating system executes a variety of programs: A program that browses the Web A program that serves Web requests

Process and Its Image An operating system executes a variety of programs: A program that browses the Web A program that serves Web requests Recap of the Last Class System protection and kernel mode System calls and the interrupt interface Processes Process concept A process s image in a computer Operations on processes Context switches and

More information

csci3411: Operating Systems

csci3411: Operating Systems csci3411: Operating Systems Lecture 3: System structure and Processes Gabriel Parmer Some slide material from Silberschatz and West System Structure System Structure How different parts of software 1)

More information

Chapter 3: Process Concept

Chapter 3: Process Concept Chapter 3: Process Concept DM510-14 Chapter 3: Process Concept Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server

More information

Operating System. Chapter 3. Process. Lynn Choi School of Electrical Engineering

Operating System. Chapter 3. Process. Lynn Choi School of Electrical Engineering Operating System Chapter 3. Process Lynn Choi School of Electrical Engineering Process Def: A process is an instance of a program in execution. One of the most profound ideas in computer science. Not the

More information

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1

Reading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1 Reading Assignment 4 Chapter 4 Threads, due 2/7 1/31/13 CSE325 - Processes 1 What s Next? 1. Process Concept 2. Process Manager Responsibilities 3. Operations on Processes 4. Process Scheduling 5. Cooperating

More information

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

Process a program in execution; process execution must progress in sequential fashion. Operating Systems Process Concept An operating system executes a variety of programs: Batch system jobs Time-shared systems user programs or tasks 1 Textbook uses the terms job and process almost interchangeably Process

More information

2 Processes. 2 Processes. 2 Processes. 2.1 The Process Model. 2.1 The Process Model PROCESSES OPERATING SYSTEMS

2 Processes. 2 Processes. 2 Processes. 2.1 The Process Model. 2.1 The Process Model PROCESSES OPERATING SYSTEMS OPERATING SYSTEMS PROCESSES 2 All modern computers often do several things at the same time. A modern operating system sees each software as a process. When a user PC is booted, many processes are secretly

More information

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission

Process. Heechul Yun. Disclaimer: some slides are adopted from the book authors slides with permission Process Heechul Yun Disclaimer: some slides are adopted from the book authors slides with permission 1 Recap OS services Resource (CPU, memory) allocation, filesystem, communication, protection, security,

More information

Part V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection

Part V. Process Management. Sadeghi, Cubaleska RUB Course Operating System Security Memory Management and Protection Part V Process Management Sadeghi, Cubaleska RUB 2008-09 Course Operating System Security Memory Management and Protection Roadmap of Chapter 5 Notion of Process and Thread Data Structures Used to Manage

More information

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 3: Process. Zhi Wang Florida State University

COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 3: Process. Zhi Wang Florida State University COP 4610: Introduction to Operating Systems (Spring 2016) Chapter 3: Process Zhi Wang Florida State University Contents Process concept Process scheduling Operations on processes Inter-process communication

More information

CS 550 Operating Systems Spring Inter Process Communication

CS 550 Operating Systems Spring Inter Process Communication CS 550 Operating Systems Spring 2019 Inter Process Communication 1 Question? How processes communicate with each other? 2 Some simple forms of IPC Parent-child Command-line arguments, wait( ), waitpid(

More information

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018 CSCE 311 - Operating Systems Interrupts, Exceptions, and Signals Qiang Zeng, Ph.D. Fall 2018 Previous Class Process state transition Ready, blocked, running Call Stack Execution Context Process switch

More information

Today: Process Management. The Big Picture So Far. What's in a Process? Example Process State in Memory

Today: Process Management. The Big Picture So Far. What's in a Process? Example Process State in Memory The Big Picture So Far Today: Process Management From the Architecture to the OS to the User: Architectural resources, OS management, and User Abstractions. A process as the unit of execution. Hardware

More information

CSC Systems Programming Fall Lecture - XXIII Final Review. Tevfik Koşar. Louisiana State University

CSC Systems Programming Fall Lecture - XXIII Final Review. Tevfik Koşar. Louisiana State University CSC 4304 - Systems Programming Fall 2008 Lecture - XXIII Final Review Tevfik Koşar Louisiana State University December 4 th, 2008 1 Using make 2 Implicit Rules 3 Using Variables in Makefiles 4 Libraries

More information

Using make. Using Variables in Makefiles. Implicit Rules. Static vs Dynamic Libraries. Libraries. Tevfik Ko!ar

Using make. Using Variables in Makefiles. Implicit Rules. Static vs Dynamic Libraries. Libraries. Tevfik Ko!ar CSC 4304 - Systems Programming Fall 2008 Using make Lecture - XXIII Final Review Tevfik Ko!ar Louisiana State University December 4 th, 2008 1 2 Implicit Rules Using Variables in Makefiles 3 4 Libraries

More information

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems

Dr. D. M. Akbar Hussain DE5 Department of Electronic Systems Process /Task 1 Process Management Creation & termination of processes (user + System) Interleaving the execution of processes Scheduling of processes Synchronization mechanism between processes Communication

More information

Process Description and Control. Chapter 3

Process Description and Control. Chapter 3 Process Description and Control Chapter 3 Contents Process states Process description Process control Unix process management Process From processor s point of view execute instruction dictated by program

More information