Section 2 Processes January 27rd, 2017 Taught by Joshua Don.

Slides:



Advertisements
Similar presentations
1 CS345 Operating Systems Φροντιστήριο Άσκησης 1.
Advertisements

University of Washington Today Midterm grades posted  76. HW 3 due Lab 4 fun! 1.
Process Control Hua LiSystems ProgrammingCS2690Process Control Page 1 of 41.
CS 4284 Systems Capstone Project 2 Hints Slides created by Jaishankar Sundararaman.
UNIX Process Control Bach 7 Operating Systems Course Hebrew University Spring 2007.
1 Processes Professor Jennifer Rexford
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Advanced Programming in the UNIX Environment Hop Lee.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Lecture Topics: 11/3 Address spaces Memory protection Creating a process –NT style –Unix style.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Today’s Topics Introducing process: the basic mechanism for concurrent programming –Process management related system calls Process creation Process termination.
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
The Structure of Processes. What is a Process? an instance of running program Program vs process(task) Program : just a passive collection of instructions.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Creating and Executing Processes
More on UART Interrupts; System Calls Reference on Interrupt Identification Register(IIR) slide 17 of
Computer Studies (AL) Operating System Process Management - Process.
Shell (Addendum). Example r What if we want to support something like this: m ps –le | sort r One process should execute ps –le and another should execute.
Operating Systems Processes 1.
Operating Systems Process Creation
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,
Process Management Azzam Mourad COEN 346.
Project 2: User Programs Abdelmounaam Rezgui Acknowledgment: The content of some slides is partly taken from Josh Wiseman’s presentation.
1 A Seven-State Process Model. 2 CPU Switch From Process to Process Silberschatz, Galvin, and Gagne  1999.
Project 2: User Programs Presented by Min Li 26 Feb 2009.
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)
Tutorial 3. In this tutorial we’ll see Fork() and Exec() system calls.
OPERATING SYSTEMS 3 - PROCESSES PIETER HARTEL 1. Principle of concurrency - giving a process the illusion that it owns the whole machine  A process has:
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.
1 Intro to the Shell with Fork, Exec, Wait Sarah Diesburg Operating Systems CS 3430.
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
Linux/UNIX Programming APUE (Process Control) 문양세 강원대학교 IT 대학 컴퓨터과학전공.
The Shell What does a shell do? - execute commands, programs - but how? For built in commands run some code to do the command For other commands find program.
A process is a program in execution A running system consists of multiple processes – OS processes Processes started by the OS to do “system things” –
Section 8: Processes What is a process Creating processes Fork-Exec
Jaishankar Sundararaman
Protection of System Resources
Unix Process Management
Processes A process is a running program.
Processes in Unix, Linux, and Windows
UNIX PROCESSES.
Programming Assignment 1
Processes in Unix, Linux, and Windows
Lecture 5: Process Creation
More on UART Interrupts; System Calls
More examples How many processes does this piece of code create?
Processes in Unix, Linux, and Windows
System Structure and Process Model
Mid Term review CSC345.
Recitation 9: Processes, Signals, TSHLab
Process Creation Process Termination
Tutorial 3 Tutorial 3.
The Environment of Unix Process
Jonathan Walpole Computer Science Portland State University
Lecture 6: Multiprogramming and Context Switching
dup, dup2 An existing file descriptor (filedes) is duplicated
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
Process Description and Control in Unix
Process Description and Control in Unix
Outline Chapter 3: Processes Chapter 4: Threads So far - Next -
Intro to the Shell with Fork, Exec, Wait
Recitation 9: Processes, Signals, TSHLab
Presentation transcript:

Section 2 Processes January 27rd, 2017 Taught by Joshua Don

Quick 61C Review char *string = “hello”; 0xFFF..FF 0x000..00 Stack Heap Text char *string = “hello”; int main(int argc, char* argv[]) { int x = 10; char *another_string = malloc(10); } Where is string? argc? x? another_string?

Quick 61C Review char *string = “hello”; 0xFFF..FF 0x000..00 Stack Heap Text char *string = “hello”; int main(int argc, char* argv[]) { int x = 10; char *another_string = malloc(10); } Where is string? Text argc? Stack x? Stack another_string? Stack, but it points to a loc on the heap

Dual Mode Operation Two modes of operation. User and kernel mode. We want to protect ourselves from user programs which can’t be trusted and other processes from each other. Examples of procedures that are in kernel mode? How do we get in kernel mode?

Dual Mode Operation Two modes of operation. User and kernel mode. We want to protect ourselves from user programs which can’t be trusted and other processes from each other. Examples of procedures that are in kernel mode? Scheduling Handling interrupts Filesystem management How do we get in kernel mode? Syscall (a programmatic interface to the kernel) Interrupt (asynchronous event ie. Timer going off) Exception (synchronous event ie. Divide by 0)

Fork

Fork Process A 0xFFF..FF Stack int main() { . . . pid_t p = fork() } Heap Text int main() { . . . pid_t p = fork() }

Fork continued Process A 0xFFF..FF Stack int main() { . . . Heap Text int main() { . . . pid_t p = fork() } Fork!!!!

Fork continued Process A Process B (PID = 1) 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF 0x000..00 Stack Heap Text int main() { . . . pid_t p = fork() } int main() { . . . pid_t p = fork() }

Fork continued Process A Process B (PID = 1) 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF 0x000..00 Stack Heap Text int main() { . . . pid_t p = fork() } int main() { . . . pid_t p = fork() } 1

Wait

wait() function signature is wait(int *status) “waits” for any child process to terminate. wait(&status) same as waitpid(-1, &status, 0) waitpid generally used to wait on a specific child (first argument to waitpid is the PID of the process to wait on) -1 in this case means “any child”, so it is equivalent to wait()

Wait continued int main() { int status; pid_t p = fork() if (p != 0){ Process A Process B (PID = 1) 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF 0x000..00 Stack Heap Text int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0); int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0);

Wait continued int main() { int status; pid_t p = fork() if (p != 0){ Process A Process B (PID = 1) 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF 0x000..00 Stack Heap Text int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0); int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0);

Wait continued int main() { int status; pid_t p = fork() if (p != 0){ Process A Process B (PID = 1) 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF 0x000..00 Stack Heap Text int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0); int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0);

Wait continued int main() { int status; pid_t p = fork() if (p != 0){ Process A Process B (PID = 1) 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF 0x000..00 Stack Heap Text int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0); int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0);

Wait continued int main() { int status; pid_t p = fork() if (p != 0){ Process A Process B (PID = 1) 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF 0x000..00 Stack Heap Text int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0); int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0);

Wait continued int main() { int status; pid_t p = fork() if (p != 0){ Process A Process B (exit code = 0) 0xFFF..FF 0x000..00 Stack Heap Text int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } exit(0);

Exec

Exec Process B Process A 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } else { exec(“/bin/ls”); } exit(0); int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } else { exec(“/bin/ls”); } exit(0);

Exec continued Process B Process A 0xFFF..FF 0x000..00 Stack Heap Text int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } else { exec(“/bin/ls”); } exit(0); int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } else { exec(“/bin/ls”); } exit(0);

Exec continued Process B Process A 0xFFF..FF 0x000..00 Stack Heap Text int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } else { exec(“/bin/ls”); } exit(0); int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } else { exec(“/bin/ls”); } exit(0);

Exec continued Process B Process A int main() { // code for // /bin/ls 0xFFF..FF 0x000..00 Stack Heap Text 0xFFF..FF 0x000..00 Stack Heap Text Process A Process B int main() { int status; pid_t p = fork() if (p != 0){ // parent wait(&status); } else { exec(“/bin/ls”); } exit(0); int main() { // code for // /bin/ls exit(0); }