Process in Unix, Linux and Windows CS-3013 C-term 20081 Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Advertisements

Chapter 3 Process Description and Control
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.
CSE 451: Operating Systems Winter 2006 Module 4 Processes Ed Lazowska Allen Center 570.
Processes CSCI 444/544 Operating Systems Fall 2008.
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.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
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
CS Advanced Operating Systems Structures and Implementation Lecture 5 Processes February 11 th, 2013 Prof. John Kubiatowicz
Lecture Topics: 11/3 Address spaces Memory protection Creating a process –NT style –Unix style.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Introduction to Processes CS Intoduction to Operating Systems.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Implementing Processes and Process Management Brian Bershad.
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
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
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
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,
CS 153 Design of Operating Systems Spring 2015 Lecture 5: Processes and Threads.
Operating Systems Process Creation
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
1 A Seven-State Process Model. 2 CPU Switch From Process to Process Silberschatz, Galvin, and Gagne  1999.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
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” –
Lecture Topics: 11/1 Processes Process Management
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Processes.
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
System Structure B. Ramamurthy.
Processes in Unix, Linux, and Windows
System Structure and Process Model
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Processes Hank Levy 1.
Processes and Process Management
October 7, 2002 Gary Kimura Lecture #4 October 7, 2002
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
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
Process Description and Control in Unix
EECE.4810/EECE.5730 Operating Systems
Processes Hank Levy 1.
Process Description and Control in Unix
Presentation transcript:

Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from Operating System Concepts, 7 th ed., by Silbershatz, Galvin, & Gagne and from Modern Operating Systems, 2 nd ed., by Tanenbaum)

Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows Unix pre-empted generic term “process” to mean something very specific Linux and Windows adopted Unix definition

Process in Unix, Linux and Windows CS-3013 C-term Process in Unix-Linux-Windows comprises an address space – usually protected and virtual – mapped into memory the code for the running program the data for the running program an execution stack and stack pointer (SP); also heap the program counter (PC) a set of processor registers – general purpose and status a set of system resources –files, network connections, pipes, … –privileges, (human) user association, … …

Process in Unix, Linux and Windows CS-3013 C-term Processes – Address Space 0x xFFFFFFFF Virtual address space program code (text) static data heap (dynamically allocated) stack (dynamically allocated) PC SP See also Silbershatz, figure 3.1

Process in Unix, Linux and Windows CS-3013 C-term Processes in the OS – Representation To users (and other processes) a process is identified by its Process ID (PID) In the OS, processes are represented by entries in a Process Table (PT) –PID is index to (or pointer to) a PT entry –PT entry = Process Control Block (PCB) PCB is a large data structure that contains or points to all info about the process –Linux - defined in task_struct – over 70 fields see include/linux/sched.h –Windows XP – defined in EPROCESS – about 60 fields

Process in Unix, Linux and Windows CS-3013 C-term Processes in the OS – PCB Typical PCB contains: –execution state –PC, SP & processor registers – stored when process is not in running state –memory management info –Privileges and owner info –scheduling priority –resource info –accounting info

Process in Unix, Linux and Windows CS-3013 C-term Process – starting and ending Processes are created … –When the system boots –By the actions of another process (more later) –By the actions of a user –By the actions of a batch manager Processes terminate … –Normally – exit –Voluntarily on an error –Involuntarily on an error –Terminated (killed) by the actions a user or a process

Process in Unix, Linux and Windows CS-3013 C-term Processes – States Process has an execution state –ready: waiting to be assigned to CPU –running: executing on the CPU –waiting: waiting for an event, e.g. I/O

Process in Unix, Linux and Windows CS-3013 C-term Processes – State Queues The OS maintains a collection of process state queues –typically one queue for each state – e.g., ready, waiting, … –each PCB is put onto a queue according to its current state –as a process changes state, its PCB is unlinked from one queue, and linked to another Process state and the queues change in response to events – interrupts, traps

Process in Unix, Linux and Windows CS-3013 C-term Processes – Privileges Users are given privileges by the system administrator Privileges determine what rights a user has for an object. –Unix/Linux – Read|Write|eXecute by user, group and “other” (i.e., “world”) –WinNT – Access Control List Processes “inherit” privileges from user

Process in Unix, Linux and Windows CS-3013 C-term Process Creation – Unix & Linux Create a new (child) process – fork(); –Allocates new PCB –Clones the calling process (almost exactly) Copy of parent process address space Copies resources in kernel (e.g. files) –Places new PCB on Ready queue –Return from fork() call 0 for child child PID for parent

Process in Unix, Linux and Windows CS-3013 C-term Example of fork( ) int main(int argc, char **argv) { char *name = argv[0]; int child_pid = fork(); if (child_pid == 0) { printf(“Child of %s sees PID of %d\n”, name, child_pid); return 0; } else { printf(“I am the parent %s. My child is %d\n”, name, child_pid); return 0; } _______________________________ %./forktest Child of forktest sees PID of 0 I am the parent forktest. My child is 486

Process in Unix, Linux and Windows CS-3013 C-term Starting New Programs Unix & Linux:– –int exec (char *prog, char **argv) –Check privileges and file type –Loads program at path prog into address space Replacing previous contents! Execution starts at main() –Initializes context – e.g. passes arguments *argv –Place PCB on ready queue –Preserves, pipes, open files, privileges, etc.

Process in Unix, Linux and Windows CS-3013 C-term Executing a New Program (Linux-Unix) fork() followed by exec() Creates a new process as clone of previous one First thing that clone does is to replace itself with new program

Process in Unix, Linux and Windows CS-3013 C-term Fork + Exec – shell-like int main(int argc, char **argv) { char *argvNew[5]; int pid; if ((pid = fork()) < 0) { printf( "Fork error\n“); exit(1); } else if (pid == 0) { /* child process */ argvNew[0] = "/bin/ls"; argvNew[1] = "-l"; argvNew[2] = NULL; if (execve(argvNew[0], argvNew, environ) < 0) { printf( "Execve error\n“); exit(1); } } else { /* parent */ wait(pid); /* wait for the child to finish */ }

Process in Unix, Linux and Windows CS-3013 C-term Waiting for a Process Multiple variations of wait function Including non-blocking wait functions Waits until child process terminates Acquires termination code from child Child process is destroyed by kernel Zombie:– a process that had never been waited for Hence, cannot go away See Love, Linux Kernel Development, pp 37-38

Process in Unix, Linux and Windows CS-3013 C-term Processes – Windows Windows NT/XP – combines fork & exec –CreateProcess(10 arguments) –Not a parent child relationship –Note – privileges required to create a new process

Process in Unix, Linux and Windows CS-3013 C-term Windows, Unix, and Linux (traditional) Processes are in separate address spaces By default, no shared memory Processes are unit of scheduling A process is ready, waiting, or running Processes are unit of resource allocation Files, I/O, memory, privileges, … Processes are used for (almost) everything!

Process in Unix, Linux and Windows CS-3013 C-term A Note on Implementation Many OS implementations include (parts of) kernel in every address space Protected Easy to access Allows kernel to see into client processes –Transferring data –Examining state –…

Process in Unix, Linux and Windows CS-3013 C-term Processes – Address Space 0x xFFFFFFFF Virtual address space code (text) static data heap (dynamically allocated ) Kernel Code and Data PC SP User Space stack (dynamically allocated ) Kernel Space 32-bit Linux & Win XP – 3G/1G user space/kernel space

Process in Unix, Linux and Windows CS-3013 C-term Linux Kernel Implementation Kernel may execute in either Process context vs. Interrupt context In Process context, kernel has access to Virtual memory, files, other process resources May sleep, take page faults, etc., on behalf of process In Interrupt context, no assumption about what process was executing (if any) No access to virtual memory, files, resources May not sleep, take page faults, etc.

Process in Unix, Linux and Windows CS-3013 C-term Processes in Other Operating Systems Implementations will differ Sometimes a subset of Unix/Linux/Windows Sometimes quite different May have more restricted set of resources Often, specialize in real-time constraints

Process in Unix, Linux and Windows CS-3013 C-term Questions?

Process in Unix, Linux and Windows CS-3013 C-term Implementation of Processes Ready queue PCB or Ready queue1 PCB Ready queue1 PCB Ready queue2 PCB Ready queuen PCB …