Lecture Topics: 11/3 Address spaces Memory protection Creating a process –NT style –Unix style.

Slides:



Advertisements
Similar presentations
Processes and Threads Prof. Sirer CS 4410 Cornell University.
Advertisements

CSE 451: Operating Systems Winter 2007 Module 4 Processes Ed Lazowska Allen Center 570.
IT344 – Operating Systems Winter 2011, Dale Rowe.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Process Control Hua LiSystems ProgrammingCS2690Process Control Page 1 of 41.
CSE 451: Operating Systems Winter 2006 Module 4 Processes Ed Lazowska Allen Center 570.
1 Processes Professor Jennifer Rexford
Processes CSCI 444/544 Operating Systems Fall 2008.
CSE 451: Operating Systems Winter 2009 Module 4 Processes Mark Zbikowski Gary Kimura.
Processes. Announcements First homework is due this Wednesday by midnight First CS 415 project is up Contact me by 3:30 if you don’t have CSUGLab account.
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.
CSE-451 Processes1 Applications, Address Spaces, and Processes Separating Units of Computation.
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.
Process. Process Concept Process – a program in execution Textbook uses the terms job and process almost interchangeably A process includes: – program.
BINA RAMAMURTHY UNIVERSITY AT BUFFALO System Structure and Process Model 5/30/2013 Amrita-UB-MSES
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
CSE 451: Operating Systems Winter 2012 Processes Mark Zbikowski Gary Kimura.
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.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
CE Operating Systems Lecture 10 Processes and process management in Linux.
System calls for Process management
CS 153 Design of Operating Systems Spring 2015 Lecture 5: Processes and Threads.
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,
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
CSE-451 Processes1 Applications, Address Spaces, and Processes Separating Units of Computation.
1 A Seven-State Process Model. 2 CPU Switch From Process to Process Silberschatz, Galvin, and Gagne  1999.
Tutorial 3. In this tutorial we’ll see Fork() and Exec() system calls.
System calls for Process management Process creation, termination, waiting.
Direct memory access. IO Command includes: buffer address buffer length read or write dada position in disk When IO complete, DMA sends an interrupt request.
4.1 Operating Systems Lecture 9 Fork and Exec Read Ch
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
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” –
Protection of System Resources
Chapter 5: Threads Overview Multithreading Models Threading Issues
Unix Process Management
Process Realization In OS
Processes in Unix, Linux, and Windows
IT 344: Operating Systems Module 4 Processes
System Structure and Process Model
System Structure and Process Model
Processes in Unix, Linux, and Windows
More on UART Interrupts; System Calls
System Structure B. Ramamurthy.
More examples How many processes does this piece of code create?
Processes in Unix, Linux, and Windows
System Structure and Process Model
Process Creation Process Termination
CSE 451: Operating Systems Winter 2011 Processes
CSE 451: Operating Systems Winter 2010 Module 4 Processes
Lecture Topics: 11/1 General Operating System Concepts Processes
Tutorial: The Programming Interface
Jonathan Walpole Computer Science Portland State University
Lecture 6: Multiprogramming and Context Switching
October 7, 2002 Gary Kimura Lecture #4 October 7, 2002
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix, Linux, and Windows
CSE 451: Operating Systems Autumn 2009 Module 4 Processes
IT 344: Operating Systems Winter 2008 Module 4 Processes
CSE 451: Operating Systems Winter 2007 Module 4 Processes
Processes in Unix and Windows
CS510 Operating System Foundations
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
Section 2 Processes January 27rd, 2017 Taught by Joshua Don.
Presentation transcript:

Lecture Topics: 11/3 Address spaces Memory protection Creating a process –NT style –Unix style

Address Spaces An address space is the range of addresses that a process may use The legal address space is the range of addresses that a process may use right now Reserved Text Static data Dynamic data and stack Operating system

User and Kernel Memory When the mode bit is set to privileged, the kernel can see all of memory –user program, arguments, etc. –user memory is like a big data structure to the kernel When the mode bit is off, the user program can only see its own memory –the kernel’s part of the address space is off limits

Enforcing Kernel Memory To enforce this policy, the hardware must check every reference to make sure it’s OK Address: Mode bit’: 0 exception

Multiple Address Spaces Nearly all modern operating systems support the abstraction of multiple address spaces 0xffffffff 0x kernel netscape 0x7fffffff 0x wordtetris user mode kernel mode

Processes and Address Spaces Each process has its own address space Process A’s memory references (loads and stores) are interpreted within process A’s address space Can Process A load a word from Process B’s address space? Can Process A load a word from kernel memory?

Memory Protection We mean two things by memory protection: –user programs can’t access kernel memory –user programs can’t access each other’s memory In the first case, we’re using hardware support In the second case, we’re using naming

Process Creation We’ll see two approaches The NT way: the directed approach –The parent process issues a series of system calls, setting up the child The Unix way: fork/exec –The parent clones itself, and the child alters itself to do its task

Directed Process Creation 1/3 Step 1: Ask the OS to make a new address space

Directed Process Creation 2/3 Step 2: Ask the OS to write the program image into the new address space

Directed Process Creation 3/3 Step 3: Ask the OS to start the new process running at some procedure

Unix Process Creation Only one step: call fork() How does the OS know what program to run and where to start it?

Unix fork() Fork() is the Unix system call that creates a new process, but it doesn’t take any arguments Instead, it makes an exact duplicate of the parent process. The only differences: –The PID (process ID number) –The return value of fork() itself

An Example Using fork() main(int argc, char *argv[]) { char *myName = argv[1]; int cpid = fork(); if(cpid == 0) { printf(“The child of %s is %d\n”, myName, getpid()); exit(0); } else { printf(“My child is %d\n”, cpid); exit(0); }

Bizarre But Real sequoia> gcc -o forkexample forkexample.c sequoia>./forkexample george The child of george is My child is 23874

Even More Bizarre sequoia>./forkexample george The child of george is My child is sequoia>./forkexample george My child is The child of george is Why do we get a different answer?

What good is fork()? By itself, not very useful –You might want to run an entirely different program some day! Another system call, exec(), completes the picture. Exec(): –Replaces the program image of the parent with a new image –Starts executing at the beginning

Why is Unix Like That? The Unix assumption is that the child will have a lot in common with the parent –it will read the same files –the username of the owner is the same –it uses some of the same data, etc. The Unix approach starts with the parent and alters to suit The NT approach starts from scratch