Chapter 3

Ace your homework & exams now with Quizwiz!

process creation (according to slides)

1) assign unique PID 2) create PCB (which PID in table points to) 3) allocate memory 4) populate PCB 5) initialize PC (to program entry point), stack pointers (to define stack boundaries), state information, etc. 6) initial files (STDOUT, STDIN, STDERR) 7) process is ready SLIDE 43 DIAGRAM

five-state process model

1) running = in execution (ASSUMING A SINGLE PROCESSOR COMPUTER FOR THIS CHAPTER) 2) ready = ready for execution (has all necessary resources) 3) blocked/waiting = waiting for a resource/event (such as completion of an I/O operation) 4) new = process has been created but not yet ready (typically not yet been loaded into main memory, although its PCB has been created) 5) exit = halted/aborted/terminated execution for some reason SLIDES 19-21 FOR DIAGRAM OF THIS (PG. 113-115)

info stored in PCB (process attributes)

process id (id of this process, id of parent process, user id) processor state information - saved state when interrupted - context switching info - user-visible registers - control and status registers (PC, IR, ...) - stack pointers - GPR (general purpose registers) - PSW (contains status info) process control information - additional info needed by OS to control and coordinate the active processes - scheduling and status info (process state, priority, scheduling-related info, pending events) - interprocess communication - process privileges - memory managements - resource ownership/utilization

characteristics of a suspended process

process is not immediately available for execution process was placed in a suspended state by an agent for the purpose of preventing execution (itself, parent process, the kernel) the process may or may not be waiting on an event the process may not be removed from this state until the agent explicitly order the removal

process trace

the sequence of instructions that execute for that process

when is process created

OS builds data structures to manage the process and allocates address space in memory to the process when is a process created? - a user at a terminal attempts to log into system (OS responsible) - OS creates a process to provide a service - created by a user process (OS creates a process at the request of another process = process spawning) - parent/child relation (result of the spawning)

OS execution

OS functions same way as ordinary software (set of programs executed by the CPU) frequently relinquishes control and depends on CPU to to restore control is OS a process, if so how is it controlled --> different approaches - nonprocess kernel - execution within user processes - process-based OS

two-state process model

OS is responsible for controlling process execution - interleaving the use of the CPU - resource allocation a process is either being executed by a processor (RUNNING) or it isn't (NOT RUNNING) - LOOK AT SLIDE 13 FOR DIAGRAM when OS Creates new process, it creates a new PCB for the process and enters that process into the system in the NOT RUNNING state

process description

OS manages all resource allocation (processor, memory, I/O devices)

review of context switching and typical functions of OS in kernel mode

PG. 129-131

reasons for suspension and other uses for suspension

SLIDES 25-27 and PG. 119-120

structure of a UNIX process

U-AREA?? SLIDE 31

suspended processes

a process needs all resources to be eligible for running (in ready queue) a process is blocked when not eligible for running (preserves resources) may be swapped-out to disk (releases resources and memory moved from main to disk) blocked/suspended (suspended while waiting for a resource (in secondary memory)) ready/suspended (suspended while ready for running (in secondary memory but available for execution as soon as it is loaded into main memory))

process definition

a program in execution an instance of a program on a computer the entity that can be assigned to and executed on a processor a unity of activity characterized by the execution of a sequence of instructions, a current state, and an associated set of system resources entity as described in the Process Control Block

relationship between processes and programs

a program is a set of functions and procedures - functions may be separate processes, or they may constitute the code part of a single process - one-to-one relation (a single execution of a sequential program) - many-to-one (many "simultaneous" executions of a program; execution of a concurrent process)

processes

all multiprogramming OS's (from single to thousands of users) are built around the concept of the process OS must interleave the execution of multiple processes OS must allocate resources to processes OS must support interprocess communication and user creation of processes

Process Control Block

all the elements on the previous card are contained in the PCB created and managed by the OS all necessary info to resume an interrupted program

concurrency

an illusion of parallelism - sharing/switching - two tasks are concurrent if there is an illusion that they are being performed in parallel whereas only one of them may be performed at any time - obtained by interleaving the operation of processes on the CPU

suspended process transitions

blocked --> blocked/suspended - make room in memory for other processes (processes in ready/suspended queue) blocked/suspended --> ready/suspended - when the event it was waiting for occurs ready/suspended --> ready - no ready process, so bring one in (or may have higher priority than one that is in ready state) ready --> ready/suspended - make room in memory if can't move blocked to blocked/suspended new --> ready/suspended - not enough resources for new process

process-based OS

collection of system processes advantage = modular OS --> non-critical OS modules in separate processes useful for multiprocessor systems - specific services can have a dedicated processor (improves performance)

parallelism

events occurring at the same time - two tasks are parallel if they are performed at the same time - true parallelism obtained by using multiple CPU's (multiprocessor system)

execution within user processes

executes OS software within user space separate kernel stack process switch not necessary - only mode switch within the same process OS code and date are in shared address space - shared by all processes within a process, both a user program and OS programs may execute, and the OS programs that execute in various user process are identical DIAGRAM ON SLIDE 49 (PG. 135 - 3.15b)

UNIX SVR4 process management

follows the "execution within user process" model in which most of the OS executes within the environment of a user process system process run in kernel mode and execute OS code to perform admin functions user processes operate in user mode to execute user programs/utilities and in kernel mode to execute instructions that belong to kernel - user process enters kernel mode by issuing a system call, when an exception (fault) is generated, or when an interrupt occurs 9 process states are recognized by the UNIX SVR4 OS uniqueness: - UNIX employs two Running states to indicate whether the process is executing in user or kernel mode ("User Running" and "Kernel Running") - distinction made between "Ready to Run, in Memory" and "Preempted" --> kernel may decide to preempt a current process it is done with in favor of one that is ready and of higher priority (indicated by dotted line but for purposes of dispatching these processes form one queue)

mode switching/interrupt handling

hardware - save state of current process in predetermined location (processor state info in PCB) - load state of interrupt handler from predetermined location (set PC to starting address of IH program) - switches from user to kernel mode (so IH may include privileged instructions) - IH process interrupt... if interrupted process CAN continue: - load processor state info of interrupted process if interrupted process CANNOT continue: - save status in PCB of process - update process status in PCB of currently running process (changing to ready, blocked, etc.) - call Dispatcher and select new process/update its PCB SLIDE 46 DIAGRAM

process characteristics/elements

id - UNIQUE identifier to distinguish it from all other processes - assigned by the OS code (text), data, and stack resources CPU state - PSW and GPR - if currently executing it is in the running state

OS control structures

if OS is to manage processes and resources, it must have information about the current status of each process and resource - memory tables = used to keep track/allocation of both main (real) and secondary (virtual) memory - I/O tables = used to manage which devices/channels are assigned or free and the transfer information (source of info and destination of the transfer) - file tables = info about the existence and location and permissions of files - process tables = to mange the info about each process tables must be linked in some fashion (files are access by I/O devices)(configuration files tell OS which tables to create) SLIDE 30 DIAGRAM

process switching

interrupts --> control is first transferred to an interrupt handler then branches to an OS routine that is concerned with the particular type of interrupt - clock, I/O, memory fault - CAUSE = external to the execution of the current process - USE = reaction to an asynchronous external event traps --> if error/exception condition is fatal then moved to Exit state and process switch occurs, if not then depends on nature of error and design of OS - illegal instruction - CAUSE = associated with the execution of the current instruction - USE = handling an error or an exceptional condition supervisor call - request for service - CAUSE = explicit request - USE = call to an OS function

nonprocess kernel

kernel executes separate from user processes context switching to service requests OS has its own separate memory space and system stack for procedure calls and returns

process creation in UNIX

made by means of the kernel system call, fork( ): 1) allocates a slot in process table for new process 2) assigns unique process ID to child 3) makes copy of process image of parent 4) increments counters for any files owned by parent (to reflect additional process owns these files) 5) assigns child to the Ready to Run state 6) returns the ID number of child to parent process and a 0 value to child process ** all of this work is accomplished in kernel mode in the parent process

role of the PCB

most important data structure in an OS contains all process info needed by OS used by all OS modules - scheduling - interrupt processing - resource allocation one PCB per process - unique id index into a table of pointers to the PCB's SLIDE 35 DIAGRAM

process termination

normal completion (requests service to OS) time limit exceeded memory unavailable I/O failure MANY MORE (SLIDE 18)

process control structure

to manage and control a process, the OS must know where it is located and the attributes of the process physical manifestation of a process = - program or set of programs to be executed - set of data and stack (stack used to keep track of procedure calls and parameters passing between procedures) - attributes used by OS for process control = PCB the collection of program, data, stack, and attributes = PROCESS IMAGE location of process image depends on memory management scheme being used typical elements of process image = user data, user program, stack, and PCB

process elements

two essential elements of a process: 1) program code - which may be shared with other processes 2) a set of data associated with that code - when the process begins to execute the program code, we refer to this executing entity as a process

UNIX process image

user-level context - process text, data, user stack, shared memory register context - PC, processor status register, stack pointer, GPRs system-level context - process table entry - U (user) area = contains additional process control info needed by kernel when it is executing in context of this process **** UNIX kernel always executes in the context of some process (reason for U area)

process creation (according to book)

when OS decides, for reasons on previous card, to create a new process: 1) assign a unique process id (new entry to primary process table) 2) allocate space for the process (for all elements of the process image) - must know how much space is needed for private user address space (programs and data) and user stack - can be assigned by default based on type of process or can be set based on user request at job creation time - if spawned by another process, parent process can pass needed space values - finally, space for a PCB must be allocated 3) initialize the PCB - initialize PC to program entry point - stack pointers to define the process stack boundaries - other state information mostly start at zero 4) set appropriate linkages 5) create or expand other data structures


Related study sets

NSG 330 Ch 29- Management of Complications from Heart Disease

View Set

Producer Licensing, and Other Regulations

View Set

Biology 101 - Midterm (Units 1-4)

View Set

Chapter 7: The News and Social Media POLS 1336 UH

View Set

Exam 3 Sole Ch. 14-16 IGGY Ch. 32, 44-45, 68

View Set