Concurrent Processes Processes can concurrently run same program. Processes can concurrently run same program. Processes can start other processes. Processes.

Slides:



Advertisements
Similar presentations
Process Management.
Advertisements

1 CS345 Operating Systems Φροντιστήριο Άσκησης 1.
Week Fourteen Agenda Announcements Final Exam True/False -100 questions (1 point per question) Multiple Choice - 40 questions (2 points per question)
Process Control Hua LiSystems ProgrammingCS2690Process Control Page 1 of 41.
CS 311 – Lecture 14 Outline Process management system calls Introduction System calls  fork()  getpid()  getppid()  wait()  exit() Orphan process.
Page 1 Task Control: Signals and Alarms Chapter 7 and 8 B. Ramamurthy.
Exec function Exec function: - replaces the current process (its code, data, stack & heap segments) with a new program - the new program starts executing.
CS Lecture 15 Outline Process Management System calls – exec() – chdir() – system() – nice() – Accessing User and Group IDs – Redirection Lecture.
Process Process: the UNIX abstraction of a stand-along computer that manages resources (memory, CPU, I/O resources) comprising a running program. Processes.
Signals Hua LiSystems ProgrammingCS2690Signals. Topics: Sending Signals -- kill(), raise() Signal Handling -- signal() sig_talk.c -- complete example.
Process Control in Unix Operating Systems Hebrew University Spring 2004.
CS Lecture 16 Outline Inter-process Communication (IPC) – Pipes – Signals Lecture 161CS Operating Systems 1.
CSSE Operating Systems
Shells, System Calls, and Signals. What is a Shell? A shell is a command line interface to the operating system – Fetch a command from the user and execute.
Fork and Exec Unix Model Tutorial 3. Process Management Model The Unix process management model is split into two distinct operations : 1. The creation.
University of Pennsylvania 9/12/00CSE 3801 Multiprogramming CSE 380 Lecture Note 3.
Process Control. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor utilization while providing.
Shell (Part 1). Process r A process is an instance of an application running r If there are two instances of an application running then there are two.
Fundamentals CIS 552. Fundamentals Low-level I/O (read/write using system calls)  Opening/Creating files  Reading & Writing files  Moving around in.
Today’s Topics Introducing process: the basic mechanism for concurrent programming –Process management related system calls Process creation Process termination.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Creating and Executing Processes
Week Fourteen Agenda Announcements Final Exam True/False -100 questions (1 point per question) Multiple Choice - 40 questions (2 points per question)
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
System calls for Process management
Unix Process Model Simple and powerful primitives for process creation and initialization. fork syscall creates a child process as (initially) a clone.
Scis.regis.edu ● CS 468: Advanced UNIX Class 5 Dr. Jesús Borrego Regis University 1.
Week Fourteen Agenda Announcements Final Exam True/False -100 questions (1 point per question) Multiple Choice - 40 questions (2 points per question)
Operating Systems Process Creation
CS4315A. Berrached:CMS:UHD1 Process Management Chapter 6.
What is a Process? u A process is an executable “cradle” in which a program may run u This “cradle” provides an environment in which the program can run,
Signals and Signal Processing CIS 370 Lab 7 Umass Dartmouth.
Signals (Chap 10 in the book “Advanced Programming in the UNIX Environment”) Acknowledgement : Prof. Y. Moon at Kangwon Nat’l Univ.
UNIX Signals * POSIX-Defined Signals * Signaling Processes * Signal Mask * sigaction * kill and sigaction * alarm * Interval Timers * POSIX.1b Timers *
CSCI 330 UNIX and Network Programming Unit XII: Process & Pipe Part 1.
Process Management Azzam Mourad COEN 346.
CSCI 330 UNIX and Network Programming
ACCESS CONTROL. Components of a Process  Address space  Set of data structures within the kernel - process’s address space map - current status - execution.
S -1 Processes. S -2 wait and waitpid (11.2) Recall from a previous slide: pid_t wait( int *status ) wait() can: (a) block; (b) return with status; (c)
The Process CIS 370, Fall 2009 CIS UMassD. The notion of a process In UNIX a process is an instance of a program in execution A job or a task Each process.
Tutorial 3. In this tutorial we’ll see Fork() and Exec() system calls.
System calls for Process management Process creation, termination, waiting.
Dsh: A Devil Shell COMPSCI210 Recitation 14 Sep 2012 Vamsi Thummala.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
1 Unix system calls fork( ) wait( ) exit( ). 2 How To Create New Processes? n Underlying mechanism -A process runs fork to create a child process -Parent.
CS241 Systems Programming Discussion Section Week 2 Original slides by: Stephen Kloder.
4.1 Operating Systems Lecture 9 Fork and Exec Read Ch
Process Related System Calls By Neha Hulkoti & Kavya Bhat.
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
UNIX signals.
Task Control: Signals and Alarms Chapter 7 and 8
Protection of System Resources
Real Time Programming Tech.
Unix Process Management
UNIX PROCESSES.
Tarek Abdelzaher Vikram Adve Marco Caccamo
Processes in Unix, Linux, and Windows
Shells, System Calls, and Signals
Fork and Exec Unix Model
CSC Advanced Unix Programming, Fall 2015
System Structure and Process Model
Tutorial 3 Tutorial 3.
Operation System Program 1
Process Programming Interface
Inter-Process Communication ENCE 360
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
Process Description and Control in Unix
Process Description and Control in Unix
System Programming: Process Management
Presentation transcript:

Concurrent Processes Processes can concurrently run same program. Processes can concurrently run same program. Processes can start other processes. Processes can start other processes. UNIX provides concurrency functions UNIX provides concurrency functions

Creating New Processes system -- makes a shell system -- makes a shell Exec -- replace this process with a new one Exec -- replace this process with a new one Fork -- start a concurrent process Fork -- start a concurrent process

Example “ System ” int main() { char buffer[80]; strcpy(buffer, “ wc *.* ” ); system(buffer); }

The exec( ) Family char *path, *file; char *arg0, *arg1,..., *argn; char *argv[ ]; int ret; ret = execl (path, arg0, arg1,..., argn, (char *)0); ret = execv (path, argv); ret = execlp (file, arg0, arg1,..., argn, (char *) 0); ret = execvp (file, argv);

The fork( ) Facility Basic process creation primitive. Basic process creation primitive. Duplicates the calling process. Duplicates the calling process. New process child process New process child process Initiating process is parent. Initiating process is parent. Returns child ’ s process-id Returns child ’ s process-id

Inherited Data and File Descriptors Forked child has instances of current values of the variables and open file descriptors. Forked child has instances of current values of the variables and open file descriptors. Variables; “ pass ” by copy Variables; “ pass ” by copy Read/write pointers for a file; reference Read/write pointers for a file; reference

wait( ) int wait (int * status) int wait (int * status) Suspends execution of process while child runs Suspends execution of process while child runs Parent resumes upon child termination Parent resumes upon child termination When the first child process terminates When the first child process terminates Normally returns process-id of exiting child. Normally returns process-id of exiting child. On error, wait( ) returns a -1, usually meaning no child exists on which to wait. On error, wait( ) returns a -1, usually meaning no child exists on which to wait.

Zombies and Premature Exits Zombie processes are ones that somehow lose connection with the parent. How? Zombie processes are ones that somehow lose connection with the parent. How? Zombie occupies a slot in process table, but uses no system resources. Zombie occupies a slot in process table, but uses no system resources. Zombie cleared when parent “ claims ” child Zombie cleared when parent “ claims ” child Wait removes chance of zombie??? Wait removes chance of zombie??? Parent exits B4 children  premature exit Parent exits B4 children  premature exit

Process and Group Id ’ s pid = getpid( ); its own process id pid = getpid( ); its own process id pid = getppid( ); parent process id pid = getppid( ); parent process id newpg = setpgrp( ); change group newpg = setpgrp( ); change group pgid = getpgrp( ); access group pgid = getpgrp( ); access group

UNIX Signals SIGHUP- The hangup signal, sent upon user logout SIGINT- Interrupt signal, sent on user break signal SIGQUIT- Quit signal, sent when user hits quit key SIGILL - Illegal Instruction signal SIGTRAP- Trace trap signal used by debuggers SIGFPE- Floating-Point exception signal SIGKILL- Sent process n to terminate process m SIGSYS- Bad argument to a system call signal SIGPIPE- Write on a pipe with no one to read it SIGALRM- Alarm clock signal used for software timers SIGTERM- Software signal to terminate process SIGUSR1- user signal SIGUSR2- user signal

pause( ) int pause( ) pause( ) suspends the calling process, without wasting resources, until some kind of signal is received.