Exec Function calls Used to begin a processes execution. Accomplished by overwriting process imaged of caller with that of called. Several flavors, use.

Slides:



Advertisements
Similar presentations
Processes Management.
Advertisements

A. Frank - P. Weisberg Operating Systems Process Scheduling and Switching.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
Processes CSCI 444/544 Operating Systems Fall 2008.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
CMPT 300: Operating Systems I Ch 3: Processes Dr. Mohamed Hefeeda
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
1/26/2007CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Some Example C Programs. These programs show how to use the exec function.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operation on Processes.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Processes: program + execution state
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
8-Sep Operating Systems Yasir Kiani. 8-Sep Agenda for Today Review of previous lecture Process scheduling concepts Process creation and termination.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Processes. Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
Computer Studies (AL) Operating System Process Management - Process.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
11/13/20151 Processes ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original.
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Process Description and Control
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
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,
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Q:Process Stateu 有哪些 ? 何種情形下會做 transition? As a process executes, it.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
Lecture 4: Processes & Threads. Lecture 4 / Page 2AE4B33OSS Silberschatz, Galvin and Gagne ©2005 Contents The concept of Process Process states and life-cycle.
 Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
ITC250 Copyright 2008© ITC 1 Assessment -4- Choose the correct answer.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 8 Processes II Read Ch.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Operating System Components) These components reflect the services made available by the O.S. Process Management Memory Management I/O Device Management.
Lecture 3 Process.
Processes and threads.
Chapter 3: Processes.
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
Sujata Ray Dey Maheshtala College Computer Science Department
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process-Concept
Chapter 3: Process Concept
Chapter 3: Processes.
Chapter 3: Processes.
Process Virtualization. Process Process is a program that has initiated its execution. A program is a passive entity; whereas a process is an active entity.
Lecture 2: Processes Part 1
Operating Systems Lecture 6.
Process & its States Lecture 5.
Chapter 3: Processes.
Operating System Concepts
Processes Hank Levy 1.
Sujata Ray Dey Maheshtala College Computer Science Department
Chapter 3: Processes.
Processes – Part I.
Chapter 3: Processes Process Concept Process Scheduling
Chapter 3: Process Concept
Presentation transcript:

exec Function calls Used to begin a processes execution. Accomplished by overwriting process imaged of caller with that of called. Several flavors, use the one most suited to needs.

exec Function calls int execv( char *path, char *argv[]) ; path: directory path to executable image. Can be your program, or system program. argv: Array of pointers to null terminated strings. These are the arguments to the program being executed.

exec Function calls two conventions with argv: 1) argv[0] should hold the name of the program to be executed. 2) The last element must be NULL.

main (int argc, *argv[]) { int pid ; char *args[2] ; pid = fork() ; if (pid ==0) { args[0] = “./a.out” ;All executed by args[1] = NULL ;child process i = execv(“./aout”, args) ; printf(“OOOpppssss.\n”) ; } else printf(“Not a problem!\n”) ; Executed by parent }

int pid ; char *args[2] ; pid = fork() ;

int pid ; char *args[2] ; pid = ? fork Parent int pid ; char *args[2] ; pid = 0 Child

int pid ; char *args[2] ; pid = fork() if (pid == 0) {args[0] = “./a.out” ; args[1] = NULL ; i = execv(“./aout”, args) ; printf(“OOOpppssss.\n”) ; } else printf(“Not ….”);

Parent int pid ; char *args[2] ; pid = fork() if (pid == 0) {args[0] = “./a.out” ; args[1] = NULL ; i = execv(“./aout”, args) ; printf(“OOOpppssss.\n”) ; } else printf(“Not ….”);

Parent int pid ; char *args[2] ; pid = fork() if (pid == 0) {args[0] = “./a.out” ; args[1] = NULL ; i = execv(“./aout”, args) ; printf(“OOOpppssss.\n”) ; } else printf(“Not ….”); Child int pid ; char *args[2] ; pid = fork() if (pid == 0) {args[0] = “./a.out” ; args[1] = NULL ; i = execv(“./aout”, args) ; printf(“OOOpppssss.\n”) ; } else printf(“Not ….”);

Parent int pid ; char *args[2] ; pid = fork() if (pid == 0) {args[0] = “./a.out” ; args[1] = NULL ; i = execv(“./aout”, args) ; printf(“OOOpppssss.\n”) ; } else printf(“Not ….”); a.out

Processes: program + execution state Pseudoparallelism Multiprogramming Many processes active at once With switching: process execution is not repeatable processes should make no assumptions about timing Process consists of: Process’ core image: program, data, run-time stack Program counter, registers, stack pointer OS bookkeeping information

Process State As a process executes, it changes state new: The process is being created. running: Instructions are being executed. waiting: The process is waiting for some event to occur. ready: The process is waiting to be assigned to a process. terminated: The process has finished execution.

Diagram of Process State

X

X X

X X X

Process-Centered Operating System One way to view system: a scheduler, with processes running “on top”: Some of the processes are system processes Scheduler processprocess processprocess processprocess processprocess processprocess

Process Table One entry per process. PCB Pr 0 Pr 1 Pr 2 Pr 4 …..Pr N

PCB: Process Management registers, program counter, program status word, stack pointer process state time process started, CPU time used, children’s CPU time used alarm clock setting pending signal bits pid message queue pointers, other flag bits

PCB: Memory-Related Information pointers to text Data stack segments Pointer to page table

PCB: File-Related Information root, working directory file descriptors User ID Group ID

Process Control Block (PCB)

Context Switch (or Process Switch) Currently executing process looses control of CPU Its “context” must be saved (if not terminated) into PCS. New process is chosen for execution. New process context is restored. New process is given control of the CPU.

CPU Switch From Process to Process

Process Scheduling Queues Job queue – set of all processes in the system. Ready queue – set of all processes residing in main memory, ready and waiting to execute. Device queues – set of processes waiting for an I/O device. Process migration between the various queues.

Ready Queue And Various I/O Device Queues

Representation of Process Scheduling

Low Level Interrupt Processing Each HW device has slot in interrupt vector (IV). On interrupt, HW pushes PC, PSW, one or more registers. Loads in new PC from IV. END OF HW Assembly code to save registers and info on stack (to PCB). Assembly sets up new stack for handling process. Calls C interrupt handling routing to complete interrupt processing. Scheduler is called and determines next process to run. Assembly language restores registers and other necessary items (e.g., memory map) of selected process and begins its execution.

Schedulers Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue. Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU.

Schedulers (Cont.) Short-term scheduler is invoked very frequently (milliseconds)  (must be fast). Long-term scheduler is invoked very infrequently (seconds, minutes)  (may be slow). The long-term scheduler controls the degree of multiprogramming.

Schedulers (Cont.) Processes can be described as either: I/O-bound process – spends more time doing I/O than computations, many short CPU bursts. CPU-bound process – spends more time doing computations; few very long CPU bursts.

Context Switch When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process. Context-switch time is overhead; the system does no useful work while switching. Time dependent on hardware support.

#include main() { char *ptr ; char input[1024] ; char *tmp, *tmp1 ; int i ; while(1) { i = read(0, input, 512) ; printf("Ret %d\n", i) ; ptr = input ; while (*ptr != '\n') { if (*ptr == ' ') printf("Space!\n") ; else printf("Read %c\n", *ptr) ; ptr++ ; }