Discussion of Assignments 2. Line buffered vs. full buffered I/O. Some often encountered issues in the submissions.

Size: px
Start display at page:

Download "Discussion of Assignments 2. Line buffered vs. full buffered I/O. Some often encountered issues in the submissions."

Transcription

1 3 4 Discussion of Assignment 1 Discussion of Assignments 1 and 2 Accompanying Tutorial to Operating Systems Course Alexander Holupirek, Stefan Klinger Database and Information Systems Group Department of Computer & Information Science University of Konstanz Summer Term 2009 Using System Calls for Unbuffered I/O Sample solution Same remarks on intermixing unbuffered and standard I/O Submission example: Line buffered vs. full buffered I/O Same remarks on test setups Performance graphs Hot vs. cold cache In general: Comment your code! 1 2

2 7 8 Line buffered vs. full buffered I/O Discussion of Assignments 2 Demo Rudimentary shell: Process Creation Zombie creation fork(2) and exit(3) plus missing wait(2) Describe what you are (not) doing to create a zombie. Problem description & how to get rid of them 5 Process chaining Correct usage of fork(2), exec(3) and waitpid(2) wait(2) introduces a problem here. Status of newly created process Correct usage of WIF... macros to determine process termination. Examples: Army of zombies, Fork bomb Some often encountered issues in the submissions Concepts/concepts.zombies.txt Some often encountered issues in the submissions static int exitcode = -3; // the latest exit Code 23 static char * lfunction = " none "; // the last started program 109 /** Execute any none shell command **/ 110 void execute ( char ** argv ) 111 { 112 pid_t pid = fork (); 113 lfunction = argv [0]; if( pid == 0){ // we are in the child process 116 int x = execvp (* argv, argv ); 117 exit (x); 118 } else { 119 wait (& exitcode ); // wait till the child finishes and store its exit code for later retrieval 120 } 121 } lfunction is a pointer to a string constant. No error handling for fork(2), execvp(3), wait(2). exec(2) does not return exit code of the executed program! In fact, if exec(2) returns at all (remember process chaining!) this indicates an error and -1 is returned with the global errno set to specify the error.

3 11 12 Patch osh. c : 53: osh_final. c : 52: ,14 4 # include < string.h > /* memset */ 5 # include <sys / mount.h> 6 # include <sys / param.h> 7 +# include <sys / wait.h> 8 # include < unistd.h > /* fork */ 9 # include " misc.h" # define PROMPT "[ osh ] >> " static void welcome_ message ( void ); 14 + static void execute ( char ** argv ); 15 static void cmd_help ( int argc, char ** argv ); 16 static void cmd_quit ( int argc, char ** argv ); 17 + static void cmd_ zombie ( int argc, char ** argv ); 18 + static void cmd_ status ( int argc, char ** argv ); /* status / exit code of last external command executed. */ 21 + static int status = -1; 23 /* Structure for shell command. */ 24 struct cmd_ entry { -30,9 static cmd_t cmds [] = { 26 "\t\t\ tprints this help message " }, 27 { " quit ", cmd_quit, " quit " \ 28 "\t\t\ texit the shell " }, 29 + { " zombie ", cmd_zombie, " zombie " \ 30 + "\t\t\ tcreates a zombie process " }, 31 + { " status ", cmd_status, " status " \ 32 + "\t\t\ tprints status code " \ 33 + "of last external command executed " }, 34 { NULL, NULL, NULL } 35 }; 37 +/** Create a zombie ( should be avoided in productional code ). */ 38 + static void 39 + cmd_zombie ( int argc, char ** argv ) 40 +{ 41 + ( void ) argc ; 42 + ( void ) argv ; 43 + pid_t pid ; if (( pid = fork ()) == -1) 46 + err ( errno, " fork failed."); 47 + if ( pid == 0) { 48 + /* Newly created child process. */ 49 + sleep (1); 50 + exit (0); 51 + } else { 52 + /* We are the parent and should wait (2) for our children However, we explicitly do _not_ wait to turn our 54 + children to zombies, i. e., never fetch their termination 55 + status from process control block kept in kernel. */ 56 + } 57 +} /* Examines status information ( stored by function execute ( char ** a 60 + * in global variable status */ 62 + static void 63 + cmd_status ( int argc, char ** argv ) 64 +{ 65 + ( void ) argc ; 66 + ( void ) argv ; if ( WIFEXITED ( status )) 69 + printf (" normal termination, exit status = %d\n", 70 + WEXITSTATUS ( status )); 71 + else if ( WIFSIGNALED ( status )) 72 + printf (" abnormal terminiation, signal number = %d%s\n", 73 + WTERMSIG ( status ), 74 +# ifdef WCOREDUMP 75 + WCOREDUMP ( status )? "( core file generated )" : ""); 76 +# else 77 + ""); 78 +# endif 79 + else if ( WIFSTOPPED ( status )) 80 + printf (" child stopped, signal number = %d\n", 81 + WSTOPSIG ( status )); 82 +} 10

4 /* Execute a program on user request. Spawns a new process * Termination status of last issued and terminated command 86 + * is stored in global variable status. May be examined 87 + * using internal status command ( see cmd_ status ) */ 89 + static void 90 + execute ( char ** argv ) 91 +{ 92 + pid_t pid ; if (( pid = fork ()) == -1) 95 + err ( errno, " fork failed."); 96 + else if ( pid == 0) { 97 + /* Newly created child process chaining a new command. */ 98 + int i; 99 + if ((i = execvp ( argv [0], argv )) == -1) err ( errno, " exec failed."); } fprintf ( stderr, " chained process takes forked id: %d\n", pid ); /* Wait for our children and store their exit status. */ if ( waitpid ( pid, & status, 0) == -1) err ( errno, " waitpid failed."); 106 +} -75,10 main ( void ) 112 memset ( line, 0, sizeof ( line )); 113 while ( getline ( PROMPT, line, sizeof ( line ))!= NULL ) { 114 argv = get_args ( line, & argc ); if ( argc > 0) if ( argc > 0) { 117 for ( cmd = cmds ; cmd - > func!= NULL ; cmd ++) if ( strcmp ( argv [0], cmd -> name ) == 0) if ( strcmp ( argv [0], cmd -> name ) == 0) { 120 cmd -> func (argc, argv ); break ; } if (cmd -> func == NULL ) /* No internal command has been found Trying to launch external. */ execute ( argv ); } 128 free_args ( argv ); 129 } 130 return (0); Examine termination status Macros to examine termination status POSIX.1 macros Integer status returned by wait(2) and waitpid(2) is implementation defined. Certain bits indicate exit status (for a normal return) Other bits indicate the signal number (for an abnormal termination) A bit may be set if a core file has been generated. POSIX.1 specifies that the termination status is to be looked at using various macros that are defined in <sys/wait.h>.

5 Options to waitpid(2) Fork bomb, Army of zombies Demo 17 18

Week 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430

Week 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430 Week 2 Intro to the Shell with Fork, Exec, Wait Sarah Diesburg Operating Systems CS 3430 1 Why is the Shell Important? Shells provide us with a way to interact with the core system Executes programs on

More information

Process management 1

Process management 1 Process management 1 The kernel The core set of service that the OS provides 2 User Mode & kernel mode User mode apps delegate to system APIs in order to access hardware User space Kernel space User Utilities

More information

CSC 1600 Unix Processes. Goals of This Lecture

CSC 1600 Unix Processes. Goals of This Lecture CSC 1600 Unix Processes q Processes Goals of This Lecture q Process vs. program q Context switching q Creating a new process q fork: process creates a new child process q wait: parent waits for child process

More information

UNIX Processes. by Armin R. Mikler. 1: Introduction

UNIX Processes. by Armin R. Mikler. 1: Introduction UNIX Processes by Armin R. Mikler Overview The UNIX Process What is a Process Representing a process States of a process Creating and managing processes fork() wait() getpid() exit() etc. Files in UNIX

More information

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes.

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes. Unix-Linux 2 fork( ) system call is successful parent suspended child created fork( ) returns child pid to parent fork( ) returns zero value to child; zero is the pid of the swapper/scheduler process both

More information

CSCB09: Software Tools and Systems Programming. Bianca Schroeder IC 460

CSCB09: Software Tools and Systems Programming. Bianca Schroeder IC 460 CSCB09: Software Tools and Systems Programming Bianca Schroeder bianca@cs.toronto.edu IC 460 The plan for today Processes How to create new processes Why would you want to have a program that creates new

More information

CSC 252: Computer Organization Spring 2018: Lecture 19

CSC 252: Computer Organization Spring 2018: Lecture 19 CSC 252: Computer Organization Spring 2018: Lecture 19 Instructor: Yuhao Zhu Department of Computer Science University of Rochester Action Items: Programming Assignment 3 grades are out Programming Assignment

More information

CS 350 : COMPUTER SYSTEM CONCEPTS SAMPLE TEST 2 (OPERATING SYSTEMS PART) Student s Name: MAXIMUM MARK: 100 Time allowed: 70 minutes

CS 350 : COMPUTER SYSTEM CONCEPTS SAMPLE TEST 2 (OPERATING SYSTEMS PART) Student s Name: MAXIMUM MARK: 100 Time allowed: 70 minutes CS 350 : COMPUTER SYSTEM CONCEPTS SAMPLE TEST 2 (OPERATING SYSTEMS PART) Student s Name: MAXIMUM MARK: 100 Time allowed: 70 minutes Q1 (30 marks) NOTE: Unless otherwise stated, the questions are with reference

More information

Programming Assignment #1: A Simple Shell

Programming Assignment #1: A Simple Shell Programming Assignment #1: A Simple Shell Due: Check My Courses In this assignment you are required to create a C program that implements a shell interface that accepts user commands and executes each

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

Project 2: Shell with History1

Project 2: Shell with History1 Project 2: Shell with History1 See course webpage for due date. Submit deliverables to CourSys: https://courses.cs.sfu.ca/ Late penalty is 10% per calendar day (each 0 to 24 hour period past due). Maximum

More information

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate

More information

Process Management! Goals of this Lecture!

Process Management! Goals of this Lecture! Process Management! 1 Goals of this Lecture! Help you learn about:" Creating new processes" Programmatically redirecting stdin, stdout, and stderr" (Appendix) communication between processes via pipes"

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

Operating Systems Lab

Operating Systems Lab Operating Systems Lab Islamic University Gaza Engineering Faculty Department of Computer Engineering Fall 2012 ECOM 4010: Operating Systems Lab Eng: Ahmed M. Ayash Lab # 3 Fork() in C and C++ programming

More information

Unix Processes 1 / 31

Unix Processes 1 / 31 Unix Processes 1/31 A Unix Process Instance of a program in execution. OS loads the executable in main-memory (core) and starts execution by accessing the first command. Each process has a unique identifier,

More information

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate

More information

Princeton University. Computer Science 217: Introduction to Programming Systems. Process Management

Princeton University. Computer Science 217: Introduction to Programming Systems. Process Management Princeton University Computer Science 217: Introduction to Programming Systems Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate

More information

Lesson 2. process id = 1000 text data i = 5 pid = 1200

Lesson 2. process id = 1000 text data i = 5 pid = 1200 Lesson 2 fork: create a new process. The new process (child process) is almost an exact copy of the calling process (parent process). In this method we create an hierarchy structure for the processes,

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 16: Process and Signals Cristina Nita-Rotaru Lecture 16/ Fall 2013 1 Processes in UNIX UNIX identifies processes via a unique Process ID Each process also knows its parent

More information

CSC209H Lecture 6. Dan Zingaro. February 11, 2015

CSC209H Lecture 6. Dan Zingaro. February 11, 2015 CSC209H Lecture 6 Dan Zingaro February 11, 2015 Zombie Children (Kerrisk 26.2) As with every other process, a child process terminates with an exit status This exit status is often of interest to the parent

More information

Dept. of Computer Science & Engineering 1 Knowledge & Data Engineering Lab.

Dept. of Computer Science & Engineering 1 Knowledge & Data Engineering Lab. Process Part2 Dept. of Computer Science & Engineering 1 Process Attributes Process ID Process groups and process group ID Environment Current working and root directory User and group ID Process Priorities

More information

System Programming. Process Control II

System Programming. Process Control II Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Terminating a process

More information

Process Management 1

Process Management 1 Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate Executing new programs Shell structure Why? Creating new processes and executing

More information

CSci 4061 Introduction to Operating Systems. Processes in C/Unix

CSci 4061 Introduction to Operating Systems. Processes in C/Unix CSci 4061 Introduction to Operating Systems Processes in C/Unix Process as Abstraction Talked about C programs a bit Program is a static entity Process is an abstraction of a running program provided by

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

IC221: Systems Programming 12-Week Written Exam [SOLUTIONS]

IC221: Systems Programming 12-Week Written Exam [SOLUTIONS] IC221: Systems Programming 12-Week Written Exam [SOLUTIONS] April 2, 2014 Answer the questions in the spaces provided on the question sheets. If you run out of room for an answer, continue on the back

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs. CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs

More information

Process Management 1

Process Management 1 Process Management 1 Goals of this Lecture Help you learn about: Creating new processes Programmatically redirecting stdin, stdout, and stderr (Appendix) communication between processes via pipes Why?

More information

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 20

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 20 CS24: INTRODUCTION TO COMPUTING SYSTEMS Spring 2018 Lecture 20 LAST TIME: UNIX PROCESS MODEL Began covering the UNIX process model and API Information associated with each process: A PID (process ID) to

More information

Operating Systems, laboratory exercises. List 2.

Operating Systems, laboratory exercises. List 2. Operating Systems, laboratory exercises. List 2. Subject: Creating processes and threads with UNIX/Linux API functions. 1. Creating a process with UNIX API function. To create a new process from running

More information

Exceptions, Processes and Signals

Exceptions, Processes and Signals Exceptions, Processes and Signals Computer Systems Organization (Spring 2017) CSCI-UA 201, Section 3 Instructor: Joanna Klukowska Slides adapted from Randal E. Bryant and David R. O Hallaron (CMU) Mohamed

More information

Announcement (1) sys.skku.edu is now available

Announcement (1) sys.skku.edu is now available Processes Prof. Jin-Soo Kim( jinsookim@skku.edu) TA JinHong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Announcement (1) sys.skku.edu is now available

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

CSC209 Review. Yeah! We made it!

CSC209 Review. Yeah! We made it! CSC209 Review Yeah! We made it! 1 CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files 2 ... and C programming... C basic syntax functions

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

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C. Structure Unix architecture users Functions of the System tools (shell, editors, compilers, ) standard library System call Standard library (printf, fork, ) OS kernel: processes, memory management, file

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

Operating systems and concurrency - B03

Operating systems and concurrency - B03 Operating systems and concurrency - B03 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems and concurrency - B03 1 / 15 Introduction This lecture gives a more

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

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Communication IPC in Unix Pipes: most basic form of IPC in Unix process-process ps u jon grep tcsh // what happens? Pipe has a read-end (receive)

More information

SE350: Operating Systems

SE350: Operating Systems SE350: Operating Systems Tutorial: The Programming Interface Main Points Creating and managing processes fork, exec, wait Example: implementing a shell Shell A shell is a job control system Allows programmer

More information

CS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

CS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. CS 33 Architecture and the OS CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. The Operating System My Program Mary s Program Bob s Program OS CS33 Intro to

More information

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Communication IPC in Unix Pipes: most basic form of IPC in Unix process-process ps u jon grep tcsh // what happens? Pipe has a read-end (receive)

More information

Processes. CSE 351 Autumn Instructor: Justin Hsia

Processes. CSE 351 Autumn Instructor: Justin Hsia Processes CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun https://xkcd.com/627/

More information

518 Lecture Notes Week 3

518 Lecture Notes Week 3 518 Lecture Notes Week 3 (Sept. 15, 2014) 1/8 518 Lecture Notes Week 3 1 Topics Process management Process creation with fork() Overlaying an existing process with exec Notes on Lab 3 2 Process management

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 17: Processes, Pipes, and Signals Cristina Nita-Rotaru Lecture 17/ Fall 2013 1 Processes in UNIX UNIX identifies processes via a unique Process ID Each process also knows

More information

University of Washington What is a process?

University of Washington What is a process? What is a process? What is a program? A processor? A process? 1 What is a process? Why are we learning about processes? Processes are another abstrac'on in our computer system the process abstrac9on provides

More information

CS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. CS 33 Architecture and the OS CS33 Intro to Computer Systems XIX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. The Operating System My Program Mary s Program Bob s Program OS CS33 Intro to

More information

Processes: Introduction. CS 241 February 13, 2012

Processes: Introduction. CS 241 February 13, 2012 Processes: Introduction CS 241 February 13, 2012 1 Announcements MP2 due tomorrow Deadline and contest cutoff 11:59 p.m. Fabulous prizes on Wednesday MP3 out Wednesday: Shell (1 week) Code from this lecture

More information

fork System-Level Function

fork System-Level Function Princeton University Computer Science 217: Introduction to Programming Systems Process Management Goals of this Lecture Help you learn about: Creating new processes Waiting for processes to terminate Executing

More information

Fall 2015 COMP Operating Systems. Lab #3

Fall 2015 COMP Operating Systems. Lab #3 Fall 2015 COMP 3511 Operating Systems Lab #3 Outline n Operating System Debugging, Generation and System Boot n Review Questions n Process Control n UNIX fork() and Examples on fork() n exec family: execute

More information

Processes. CSE 351 Autumn Instructor: Justin Hsia

Processes. CSE 351 Autumn Instructor: Justin Hsia Processes CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan http://xkcd.com/292/

More information

OS Lab Tutorial 1. Spawning processes Shared memory

OS Lab Tutorial 1. Spawning processes Shared memory OS Lab Tutorial 1 Spawning processes Shared memory The Spawn exec() family fork() The exec() Functions: Out with the old, in with the new The exec() functions all replace the current program running within

More information

UNIX. Session 2. UNIX processes and forking fork system call exec system call death of process kill fork and I/O using it UNIX.

UNIX. Session 2. UNIX processes and forking fork system call exec system call death of process kill fork and I/O using it UNIX. ProgrammingII Session 2 process handling processes and forking fork system call exec system call death of process kill fork and I/O using it ProgrammingII Short Course Notes Alan Dix 1996 II/20 process:

More information

CSC209 Fall Karen Reid 1

CSC209 Fall Karen Reid 1 ' & ) ) #$ "! How user programs interact with the Operating System. Somehow we need to convert a program into machine code (object code). A compiler passes over a whole program before translating it into

More information

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm Operating Systems Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) armahmood786@yahoo.com alphasecure@gmail.com alphapeeler.sf.net/pubkeys/pkey.htm http://alphapeeler.sourceforge.net pk.linkedin.com/in/armahmood

More information

Concurrency. Stefan D. Bruda. Winter 2018

Concurrency. Stefan D. Bruda. Winter 2018 Concurrency Stefan D. Bruda Winter 2018 DOING MORE THINGS SIMULTANEOUSLY Concurrency can be achieved by multiprocessing and time-sharing Best definition for concurrency: apparently simultaneous execution

More information

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu CPSC 341 OS & Networks 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, but a program is just a file It

More information

Operating Systems. Lecture 05

Operating Systems. Lecture 05 Operating Systems Lecture 05 http://web.uettaxila.edu.pk/cms/sp2013/seosbs/ February 25, 2013 Process Scheduling, System Calls Execution (Fork,Wait,Exit,Exec), Inter- Process Communication Schedulers Long

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

Part II Processes and Threads Process Basics

Part II Processes and Threads Process Basics Part II Processes and Threads Process Basics Fall 2017 Program testing can be used to show the presence of bugs, but never to show their absence 1 Edsger W. Dijkstra From Compilation to Execution A compiler

More information

Programmation Systèmes Cours 2 Process Management Basics

Programmation Systèmes Cours 2 Process Management Basics Programmation Systèmes Cours 2 Process Management Basics Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire PPS, Université Paris Diderot 2012 2013 URL http://upsilon.cc/zack/teaching/1213/progsyst/

More information

Operating Systemss and Multicore Programming (1DT089)

Operating Systemss and Multicore Programming (1DT089) Operating Systemss and Multicore Programming (1DT089) Problem Set 1 - Tutorial January 2013 Uppsala University karl.marklund@it.uu.se pointers.c Programming with pointers The init() functions is similar

More information

Exceptional Control Flow: Exceptions and Processes

Exceptional Control Flow: Exceptions and Processes Exceptional Control Flow: Exceptions and Processes 15-213 : Introduction to Computer Systems 14 th Lecture, June 21, 2018 Instructor: Brian Railing 1 Today Exceptional Control Flow Exceptions Processes

More information

Preview. Process Control. What is process? Process identifier The fork() System Call File Sharing Race Condition. COSC350 System Software, Fall

Preview. Process Control. What is process? Process identifier The fork() System Call File Sharing Race Condition. COSC350 System Software, Fall Preview Process Control What is process? Process identifier The fork() System Call File Sharing Race Condition COSC350 System Software, Fall 2015 1 Von Neumann Computer Architecture: An integrated set

More information

Process Management! Goals of this Lecture!

Process Management! Goals of this Lecture! Process Management! 1 Goals of this Lecture! Help you learn about:" Creating new processes" Programmatically redirecting stdin, stdout, and stderr" Unix system-level functions for I/O" The Unix stream

More information

Programmation Systèmes Cours 2 Introduction to Process Management

Programmation Systèmes Cours 2 Introduction to Process Management Programmation Systèmes Cours 2 Introduction to Process Management Stefano Zacchiroli zack@pps.jussieu.fr Laboratoire PPS, Université Paris Diderot - Paris 7 6 Octobre 2011 URL http://upsilon.cc/zack/teaching/1112/progsyst/

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

Introduction to Processes

Introduction to Processes Computer Systems II Introduction to Processes 1 Review: Basic Computer Hardware CPU Instruction Register Control BUS read (disk) local buffer Disk Controller Memory Executable Disk 1 Review: Timing Problem

More information

CITS2002 Systems Programming. Creating a new process using fork() 1 next CITS2002 CITS2002 schedule

CITS2002 Systems Programming. Creating a new process using fork() 1 next CITS2002 CITS2002 schedule 1 next CITS2002 CITS2002 schedule Creating a new process using fork() fork() is very unusual because it returns different values in the (existing) parent process, and the (new) child process: the value

More information

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto Ricardo Rocha Department of Computer Science Faculty of Sciences University of Porto For more information please consult Advanced Programming in the UNIX Environment, 3rd Edition, W. Richard Stevens and

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

CS 355 Operating Systems. Keeping Track of Processes. When are processes created? Process States 1/26/18. Processes, Unix Processes and System Calls

CS 355 Operating Systems. Keeping Track of Processes. When are processes created? Process States 1/26/18. Processes, Unix Processes and System Calls CS 355 Operating Systems Processes, Unix Processes and System Calls Process User types command like run foo at keyboard I/O device driver for keyboard and screen Command is parsed by command shell Executable

More information

Creating a Shell or Command Interperter Program CSCI411 Lab

Creating a Shell or Command Interperter Program CSCI411 Lab Creating a Shell or Command Interperter Program CSCI411 Lab Adapted from Linux Kernel Projects by Gary Nutt and Operating Systems by Tannenbaum Exercise Goal: You will learn how to write a LINUX shell

More information

UNIX System Calls. Sys Calls versus Library Func

UNIX System Calls. Sys Calls versus Library Func UNIX System Calls Entry points to the kernel Provide services to the processes One feature that cannot be changed Definitions are in C For most system calls a function with the same name exists in the

More information

Q & A (1) Where were string literals stored? Virtual Address. SSE2033: System Software Experiment 2 Spring 2016 Jin-Soo Kim

Q & A (1) Where were string literals stored? Virtual Address. SSE2033: System Software Experiment 2 Spring 2016 Jin-Soo Kim Processes Prof. Jin-Soo Kim(jinsookim@skku.edu) TA - Dong-Yun Lee (dylee@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Q & A (1) Where were string literals stored?

More information

Maria Hybinette, UGA. ! One easy way to communicate is to use files. ! File descriptors. 3 Maria Hybinette, UGA. ! Simple example: who sort

Maria Hybinette, UGA. ! One easy way to communicate is to use files. ! File descriptors. 3 Maria Hybinette, UGA. ! Simple example: who sort Two Communicating Processes Hello Gunnar CSCI 6730/ 4730 Operating Systems Process Chat Maria A Hi Nice to Hear from you Process Chat Gunnar B Dup & Concept that we want to implement 2 On the path to communication

More information

COE518 Lecture Notes Week 2 (Sept. 12, 2011)

COE518 Lecture Notes Week 2 (Sept. 12, 2011) C)E 518 Operating Systems Week 2 September 12, 2011 1/8 COE518 Lecture Notes Week 2 (Sept. 12, 2011) Topics Creating a cloned process with fork() Running a new process with exec...() Textbook sections

More information

PROCESS PROGRAMMING INTERFACE

PROCESS PROGRAMMING INTERFACE Reading Reference: Textbook 1 Chapter 3 Molay Reference Text: Chapter 8 PROCESS PROGRAMMING INTERFACE Tanzir Ahmed CSCE 313 FALL 2018 Theme of Today s Lecture Talk a bit about Unix Shell Introduce some

More information

Exceptional Control Flow Part I

Exceptional Control Flow Part I Exceptional Control Flow Part I Today! Exceptions! Process context switches! Creating and destroying processes Next time! Signals, non-local jumps, Fabián E. Bustamante, 2007 Control flow! Computers do

More information

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University Processes Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Processes An instance of a program in execution. One of the most profound ideas in computer

More information

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes

CSci 4061 Introduction to Operating Systems. IPC: Basics, Pipes CSci 4061 Introduction to Operating Systems IPC: Basics, Pipes Today Directory wrap-up Communication/IPC Test in one week Communication Abstraction: conduit for data exchange between two or more processes

More information

YoLinux Tutorial: Fork, Exec and Process control

YoLinux Tutorial: Fork, Exec and Process control YoLinux Tutorial: Fork, Exec and Process control This tutorial will cover the creation of child processes and process control using fork, exec and other C library function calls using the GNU "C" compiler

More information

What is a Process. Preview. What is a Process. What is a Process. Process Instruction Cycle. Process Instruction Cycle 3/14/2018.

What is a Process. Preview. What is a Process. What is a Process. Process Instruction Cycle. Process Instruction Cycle 3/14/2018. Preview Process Control What is process? Process identifier A key concept in OS is the process Process a program in execution Once a process is created, OS not only reserve space (in Memory) for the process

More information

UNIX System Programming. Overview. 1. A UNIX System. 2. Processes (review) 2.1. Context. Pipes/FIFOs

UNIX System Programming. Overview. 1. A UNIX System. 2. Processes (review) 2.1. Context. Pipes/FIFOs UNIX System Programming Pipes/FIFOs Overview 1. A UNIX System (review) 2. Processes (review) Objectives Look at UNIX support for interprocess communication (IPC) on a single machine Review processes pipes,

More information

COE518 Lecture Notes Week 4 (Sept. 26, 2011)

COE518 Lecture Notes Week 4 (Sept. 26, 2011) coe518 (Operating Systems) Lecture Notes: Week 4 Page 1 of 11 COE518 Lecture Notes Week 4 (Sept. 26, 2011) Topics Why fork(), then exec()? The delta list structure Alternative approach to Lab 2 More on

More information

Are branches/calls the only way we can get the processor to go somewhere in a program? What is a program? A processor? A process?

Are branches/calls the only way we can get the processor to go somewhere in a program? What is a program? A processor? A process? Processes and control flow Are branches/calls the only way we can get the processor to go somewhere in a program? What is a program? A processor? A process? 1 Control Flow Processors do only one thing:

More information

Binary Search Tree 1.0. Generated by Doxygen Mon Jun :12:39

Binary Search Tree 1.0. Generated by Doxygen Mon Jun :12:39 Binary Search Tree 1.0 Generated by Doxygen 1.7.1 Mon Jun 6 2011 16:12:39 Contents 1 Binary Search Tree Program 1 1.1 Introduction.......................................... 1 2 Data Structure Index 3

More information

Multitasking. Programmer s model of multitasking. fork() spawns new process. exit() terminates own process

Multitasking. Programmer s model of multitasking. fork() spawns new process. exit() terminates own process Signals Prof. Jin-Soo Kim( jinsookim@skku.edu) TA JinHong Kim( jinhong.kim@csl.skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Multitasking Programmer s model of multitasking

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

Exceptional Control Flow Part I Oct. 28, 2009"

Exceptional Control Flow Part I Oct. 28, 2009 Exceptional Control Flow Part I Oct. 28, 2009" Control Flow" Time" Physical control flow" " inst 1 " inst 2 " inst 3 " " inst n " " 2! 3! Altering the Control Flow" Exceptional Control

More information

Processes. Operating System CS 217. Supports virtual machines. Provides services: User Process. User Process. OS Kernel. Hardware

Processes. Operating System CS 217. Supports virtual machines. Provides services: User Process. User Process. OS Kernel. Hardware es CS 217 Operating System Supports virtual machines Promises each process the illusion of having whole machine to itself Provides services: Protection Scheduling Memory management File systems Synchronization

More information

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Information Sciences and Engineering

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Information Sciences and Engineering INTERNAL ASSESSMENT TEST 2 Solutions 1. Explain the working of the waitpid() API with the help of a program. The program needs to take 2 command line arguments: the first argument should be used as the

More information

Today. Introduction to Computer Systems /18 243, Fall th Lecture. Control Flow. Altering the Control Flow.

Today. Introduction to Computer Systems /18 243, Fall th Lecture. Control Flow. Altering the Control Flow. Today Introduction to Computer Systems 15 213/18 243, Fall 2009 11 th Lecture Exceptional Control Flow Processes Instructors: Greg Ganger and Roger Dannenberg Control Flow Processors do only one thing:

More information

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman

The Process Abstraction. CMPU 334 Operating Systems Jason Waterman The Process Abstraction CMPU 334 Operating Systems Jason Waterman How to Provide the Illusion of Many CPUs? Goal: run N processes at once even though there are M CPUs N >> M CPU virtualizing The OS can

More information

Exceptional Control Flow Part I September 22, 2008

Exceptional Control Flow Part I September 22, 2008 15-213 Exceptional Control Flow Part I September 22, 2008 Topics Exceptions Process context switches Creating and destroying processes class11.ppt Control Flow Computers do only one thing: From startup

More information

Exceptional Control Flow Part I Oct. 17, 2002

Exceptional Control Flow Part I Oct. 17, 2002 15-213 The course that gives CMU its Zip! Exceptional Control Flow Part I Oct. 17, 2002 Topics Exceptions Process context switches Creating and destroying processes class16.ppt Control Flow Computers do

More information

EXPERIMENT NO : M/C Lenovo Think center M700 Ci3,6100,6th Gen. H81, 4GB RAM,500GB HDD

EXPERIMENT NO : M/C Lenovo Think center M700 Ci3,6100,6th Gen. H81, 4GB RAM,500GB HDD GROUP - C EXPERIMENT NO : 12 1. Title: Implement UNIX system calls like ps, fork, join, exec family, and wait for process management (use shell script/ Java/ C programming) 2. Objectives : - To understand

More information