Processes - Copyright © University of Il inois CS 241...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Copyright ©: University of Il inois CS 241 Staff 1 Processes Processes What is a process? How do I make one? wait for one? kill one? ¡ Birth ¡ Life ¡ Death Copyright ©: University of Il inois CS 241 Staff 2 Program or Process? Process ¡ A process is the context (the information/data) maintained for an executing program An executable instance of a program ¡ A program can have many processes ¡ Each process has a unique identifier Unix processes ¡ Process #1 is known as the 'init' process (root of the process hierarchy) Copyright ©: University of Il inois CS 241 Staff 3 What makes up a Process? Program code Machine registers Global data Stack Open files An environment Copyright ©: University of Il inois CS 241 Staff 4 Process Context Process ID ( pid ) unique integer Parent process ID ( ppid ) unique integer Current directory File descriptor table Environment VAR=VALUE pairs Pointer to program code Pointer to data Mem for global vars Pointer to stack Mem for local vars Pointer to heap Dynamically allocated memory Execution priority Signal information Copyright ©: University of Il inois CS 241 Staff 5 Unix Processes Address space ¡ The address space is a section of memory that contains the code to execute as well as the process stack Set of data structures in the kernel to keep track of that process ¡ Address space map ¡ Current status of the process ¡ Execution priority of the process ¡ Resource usage of the process ¡ Current signal mask ¡ Owner of the process Copyright ©: University of Il inois CS 241 Staff 6 Process Lifetime Some processes run from system boot to shutdown ¡ Servers & Daemons (e.g. Apache httpd server) Most processes come and go rapidly, as tasks start and complete ¡ 'unit of work' on a modern computer A process can die a premature, even horrible death (say, due to a crash) Copyright ©: University of Il inois CS 241 Staff 7 Know your process Each process has a unique identifier int myid = getpid() Copyright ©: University of Il inois CS 241 Staff 8 What is wrong with this? Know your process better… pid_t myid = getpid() ¡ pid_t: int in linux, ¡ pid_t: long in other systems Know your parent pid_t myparentid = getppid() Copyright ©: University of Il inois CS 241 Staff 9 Process Creation On creation, process needs resources ¡ CPU, memory, files, I/O devices Get resources from the OS or from the parent process ¡ Child process is restricted to a subset of parent resources ¡ Prevents many processes from overloading system Copyright ©: University of Il inois CS 241 Staff 10 Process Creation Execution ¡ Parent continues concurrently with child ¡ Parent waits until child has terminated Address space ¡ Child process is duplicate of parent process...
View Full Document

{[ snackBarMessage ]}

Page1 / 7

Processes - Copyright © University of Il inois CS 241...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online