Top Banner
www.themegallery.com LOGO ANDROID UNIX William Stallings Cluster Apple unix Windows Operating Systems G..A. van Lierop LINUX Hoofdstuk 3 Beschrijving en besturing van processen
63

Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Feb 26, 2019

Download

Documents

dinhnguyet
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

www.themegallery.com

LOGO

ANDROID

UNIX

William Stallings

Cluster

Apple

unix

Windows

Operating Systems

G..A. van LieropLINUX

Hoofdstuk 3 Beschrijving en

besturing van processen

Page 2: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Operating Systems:Internals and Design Principles

De voornaamste taak van een OS is het beheren

van processen. Het OS moet systeembronnen

toewijzen aan processen, deze in de

gelegenheid te stellen om informatie te delen en

uit te wisseelen, de bronnen van elk process

afschermen en synchronisatie met elkaar

mogelijk maken.

Page 3: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

– Een computer bestaat uiteen verzameling hardware bronnen.

– Computer toepassingen zijnontwikkeld om eenbapaalde taak uit te voeren.

– It is inefficient for applications to be written directly for a given hardware platform

• The OS was developed to provide a convenient, feature-rich, secure, and consistent interface for applications to use

• We can think of the OS as providing a uniform, abstract representation of resources that can be requested and accessed by applications BV. OS bepaald alsbronnen gedeeld of gebruiktworden. Het is abstract omdat de acties van de OS onzichtbaar zijnvoor de gebruiker

Page 4: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

OS Management van de uitvoeringvan toepassingen

• Bronnen beschikbaar gemaakt worden voorverschillende toepassingen.

• De fysieke processor schakelt tussenverschillende toepassingen.

• De processor en de I/O apparaten efficient kunnen worden gebruikt.

Page 5: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Process Elements

• Two essential elements of a process are:

• When the processor begins to execute the program code, we refer to this executing entity as a process

Program code which may be shared with other processes that are executing the

same program

A set of data associated with that code

Page 6: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

• Tijdens de uitvoering van het programma, kandit proces eenduidig gekenmerkt worden door een aantal elementen waaronder:

identifier

state priorityprogram counter

memory pointers

context data

I/O status information

accounting information

Page 7: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Proces Besturings Block

Wordt door een OS gecreerd en beheert

Contains the process elements

Makes it possible to interrupt a running process and later resume execution as if the interruption had not occurred

Key tool that allows support for multiple processes, dusmultiprogramming)

Page 8: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

BYU CS 345 Chapter 3 - Processes 8

Process ImplementationProcess

Process Control Blocks

Process

ActiveContext

Page 9: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Process States

Spoor/Trace

Het gedrag van eenindividueel process kunnenwe beschrijven aan de hand van de volgorde van instructies die voor dat proceswordt uitgevoerd.

Het gedrag van de processor beschrijvendoor te tonen hoe de sporen van de diverse processen wordenverwerven.

Toedeler/Dispatcher

Een kleinprogramma

dat de processor wisselend

toewijst aaneen ander

proces

Page 10: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Process Execution

Page 11: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Traces of Processes of Figure

3.2

• Each process runs to completion

Figure 3.3

Page 12: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Combined Trace of

Processes of Figure 3.2

Figure 3.4

Page 13: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

BYU CS 345 Chapter 3 - Processes 13

Process TraceProcess

An instruction trace reveals the overhead required to multi-process.

Page 14: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.2.1 Procesmodel met 2 toestanden

• A process may be in one of two states:

– Actief/running

– Niet actief/not-running

Page 15: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Diagram wachtrij/Queuing Diagram

Page 16: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Table 3.1 Redenen voor het creeren van een proces

3.2.2 Creeren en beeindigen van processen

Page 17: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.2.2 Creeren van processen

Process spawning

• Wanneer de OS eenprocess creert op verzoek van een anderproces.

Parent process

• is the original, creating, process

Child process

• is the new process

Page 18: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Beeindiging van processen

• Er moet een manier zijn voor een process om aan te geven dat zijn taak is voltooid.Hoeweet de OS wanneer een proces is voltooid?

• A batch job should include a HALT instruction or an explicit OS service call for termination

• Bij een gebruiker van een interactievetoepassing duidt de actie van de gebruikeraan dat een process is voltooid.

Page 19: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Normal completion The process executes an OS service call to indicate that it has

completed running.

Time limit exceeded The process has run longer than the specified total time limit. There are a number of possibilities for the type of time that is measured. These

include total elapsed time ("wall clock time"), amount of time spent

executing, and, in the case of an interactive process, the amount of time

since the user last provided any input.

Memory unavailable The process requires more memory than the system can provide.

Bounds violation The process tries to access a memory location that it is not allowed to access.

Protection error The process attempts to use a resource such as a file that it is not

allowed to use, or it tries to use it in an improper fashion, such as writing to a read-only file.

Arithmetic error The process tries a prohibited computation, such as division by zero, or

tries to store numbers larger than the hardware can accommodate.

Time overrun The process has waited longer than a specified maximum for a certain

event to occur.

I/O failure An error occurs during input or output, such as inability to find a file,

failure to read or write after a specified maximum number of tries

(when, for example, a defective area is encountered on a tape), or

invalid operation (such as reading from the line printer).

Invalid instruction The process attempts to execute a nonexistent instruction (often a result

of branching into a data area and attempting to execute the data).

Privileged instruction The process attempts to use an instruction reserved for the operating

system.

Data misuse A piece of data is of the wrong type or is not initialized.

Operator or OS intervention For some reason, the operator or the operating system has terminated

the process (e.g., if a deadlock exists).

Parent termination When a parent terminates, the operating system may automatically

terminate all of the offspring of that parent.

Parent request A parent process typically has the authority to terminate any of its

offspring.

Table 3.2

Redenen

voor het

Beeindigen

van

processen

Page 20: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.2.3 Procesmodel met 5 toestanden

Page 21: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Procestoestand bij het spoor van figuur 3.4

Page 22: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Using Two Queues

Page 23: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Multiple Blocked Queues

Page 24: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

– De noodzaak van Swapping

– involves moving part or all of a process from main memory to disk

–when none of the processes in main memory is in the Ready state, the OS swaps one of the blocked processes out on to disk into a suspend queue to make room for a new process, or a previously suspended process that is now ready to execute

– Commonly used in systems that had no virtual memory; less likely to be used with virtual memory since processsize can be controlled through thepaging mechanism.

Page 25: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Met 1 toestand opgeschort

Page 26: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Met 2 toestanden opgeschort

Page 27: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Andere toepassingen van opschorten

• 2.The process may or may not be waiting on an event

• 4. The process may not be removed from this state until the agent explicitly orders the removal

• 1. Het process is nietonmiddelijk beschikbaarvoor uitvoering

• 3.Het process werd in de toestand opgeschortgeplaatst door het process zelf of door eenander process om de uitvoering van het process te verhinderen.

Page 28: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Redenen voor het opschorten van processen

Table 3.3 Reasons for Process Suspension

Page 29: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.3 Beschrijven van processenWhat does the OS need to know to manage processes &

resources?

Page 30: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.3.1 Beheerstucturen in het besturingssysteem

Page 31: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.3.1 Beschrijven van processen

• Wordt gebruikt voor het bijhouden van het hoofdgeheugen en het secundaire geheugen.

• Processen wordenondergebracht in het secundaire geheugen met eeneenvoudige vorm van swapping.

Must include:

Toewijzen van hoofdgeheugen aanprocessen

Toewijzing van secundair geheugenaan processen

Bescherming attributen van blocks van hoofd-of virtueel geheugen

Alle info die nodig is voor het beheren van het virtuele geheugen

Page 32: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.3 Beschrijven van processen

• Used by the OS to manage the I/O devices and channels of the computer system

• At any given time, an I/O device may be available or assigned to a particular process

If an I/O operation is in progress, the OS needs to

know:

the status of the I/O operation

the location in main memory being used as the

source or destination of the I/O transfer

Page 33: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.3.1 Beschrijven van processen

• Een groot deel of zelfsalle informatie wordtbijgehouden en gebruikt door het filemanagamentsysteem. Bij anderebesturingssystemenworden veel details van het bestandbeheer aaneen OS overgelaten

•existence of files

• location on secondary memory

•current status

•other attributes

These tables provide information about:

Page 34: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.3.1 Beschrijven van processen

• Wordt bijgehouden door het beheren van processen.

• Proces tabellen moeten direct of indirect verwijzennaar geheugen, I/O en bestand tabellen e.g., pointers from each individual process entry to its data in the other three sets of tables.

• The tables themselves must be accessible by the OS and therefore are subject to memory management

• Processes are represented by a process image

Page 35: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.3.2 Beheerstructuren van processenP

roce

ss C

om

po

ne

nts

Proces Locatie

– Een process bevat ten minste 1 uit tevoeren programma of verzamelingprogramma’s.

– Een process zal daarom op zijn minstbestaan uit voldoende geheugen voorhet opslaan voor programma’s en gegevens van een process.

– Bij de uitvoering van een programmawordt vaak een Stack gebruikt voor het bijhouden van procedure aanroepenen de parameters die wordendoorgegeven tussen procedures.

Pro

cess

Att

rib

ute

s

Proces Attributen

– Voor elk process bestaat eenaantal attributen dat door het besturingssysteem wordtgebruikt voor de besturingervan. Deze verzamelingattributen wordt een Process Control Block (PCB)genoemd.

– De verzameling die bestaatuit het programma, de gebruikers gegevens, de stack en de attributen het process beeld (process image)

Page 36: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.3.2 Beheerstructuren van processenProcessattributen

• Een geavanceerd multiprogrammeringsysteem heeftveel informatie over processen nodig. Deze info is in de PCB terug te vinden.

We kunnen Informatie in het PCB groeperen tot driealgemene categorieen:

• Procesidentificatie

• Processortoestandinformatie

• processorbesturingsinformatie

Page 37: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

• Each process is assigned a unique numeric identifier– otherwise there must be a

mapping that allows the OS to locate the appropriate tables based on the process identifier

• Many of the tables controlled by the OS may use process identifiers to cross-reference process tables

• Memory tables may be organized to provide a map of main memory with an indication of which process is assigned to each region

– similar references will appear in I/O and file tables

• When processes communicate with one another, the process identifier informs the OS of the destination of a particular communication

• When processes are allowed to create other processes, identifiers indicate the parent and descendents of each process

Page 38: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Processortoestandinformatie

Program status word (PSW)

• contains condition codes plus other status information

• EFLAGS register is an example of a PSW used by any OS running on an x86 processor

Bestaat uit de inhoud van de processor registers

• user-visible registers

• control and status registers

• stack pointers

Page 39: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

X86 EFLAGS Register

Page 40: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Processorbesturingsinformatie/

• Dit is de aanvullende informatie die het besturingssyseem nodig heft voor het beheren en coordineren van de diverse actieve processen

• Forms the 3rd part of the PCB (along with process ID and processor state information)

Page 41: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating
Page 42: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Process List Structures

Page 43: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

• The most important data structure in an OS

– contains all of the information about a process that is needed by the OS

– blocks are read and/or modified by virtually every module in the OS

– defines the state of the OS

• Difficulty is not access, but protection

– a bug in a single routine could damage process control blocks, which could destroy the system’s ability to manage the affected processes

– a design change in the structure or semantics of the process control block could affect a number of modules in the OS

Page 44: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.4.2 Uitvoeringsmodi

User Mode

– Minder gepriviligieerdemodes van de processor

– Gebruikersprogrammaworden in deze modus uitgevoerd.

System Mode(control mode of kenrel modus)

– more-privileged mode van de processor

– also referred to as control mode or kernel mode

– Verbonden met het besturingssysteem

– kernel of the operating system

Page 45: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Table 3.7 Standaardfuncties van de kernel van een

besturingssysteem

Page 46: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.4.2 Creeren van processen

• Once the OS decides to create a new process it:wijst een unieke procesidentificatie toe

aan het nieuwe proces

Wijst ruimte toe aan het proces

Het PCB moet worden geinitialiseerd

De juiste koppelingen worden ingesteld

Soms moeten andere gegevensstructurenworden gemaakt of uitgebreid

Page 47: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.4.3 Wisselen van processen

Een proceswisseling kan steeds optreden wanneer het besturingssysteemde bestruring heeft overgenomen van het process dat op dit moment

wordt uitgevoerd

Page 48: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

System InterruptsInterrupt

• Oorzaak is extern aande uitvoering van het huidig proces

I/O interrupt

geheugen fout

clock interrupt

• Time slice

– the maximum amount of time that a process can execute before being interrupted

Trap

• Hangt samen met een fout of uitzonderingsconditie die wordt gegenereerd binnenhet actieve proces zelf, aan de huidige instructie.

• OS determines if the condition is fatal

– moved to the Exit state and a process switch occurs

– action will depend on the nature of the error

3.4.3 Wisselen van processen

Page 49: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

If no interrupts are pending the processor:

proceeds to the fetch stage and fetches the next instruction of the current

program in the current process

If an interrupt is pending the processor:

sets the program counter to the starting address of an interrupt handler program

switches from user mode to kernel mode so that the interrupt processing code may include privileged instructions

Page 50: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

• A mode switch is distinct from a process switch.

• A mode switch can take place without changing the state of the executing process

• However, while processing a mode switch the OS may decide a process switch is needed; e.g., if the mode switch was caused by a timer interrupt or a process request for I/O

Page 51: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

• The steps in a full process switch are:

save the context of the processor

update the process control block of the process currently in the Running state

move the process control block of this

process to the appropriate queue

select another process for execution

update the process control block of the

process selected

update memory management data

structures

restore the context of the processor to

that which existed at the time the selected

process was last switched out

If the currently running process is to be moved to another state (Ready, Blocked, etc.), then the OS must make substantial changes in its environment

Page 52: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Execution of the Operating System

Page 53: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Execution Within User Processes

Page 54: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

3.5 Procesbeheer in Unix SVR4

• Uses the model where most of the OS executes within the environment of a user process

• Two process categories: system processes and user processes• System processes run in kernel mode

– executes operating system code to perform administrative and housekeeping functions independent of any specific user process.

• User Processes– operate in user mode to execute user programs and utilities– operate in kernel mode to execute instructions that belong to the kernel– enter kernel mode by issuing a system call, when an exception is

generated, or when an interrupt occurs

Page 55: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

UNIX Process States

Page 56: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

UNIX Process State Transition Diagram

Page 57: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

A Unix Process

Page 58: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Table 3.11 UNIX Process Table Entry

Page 59: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Table 3.12UNIX U

Area

Page 60: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

• Process creation is by means of the kernel system call, fork( )

• This causes the OS, in Kernel Mode, to:

1•Allocate a slot in the process table for the new process

2•Assign a unique process ID to the child process

3

•Make a copy of the process image of the parent, with the exception of any shared memory

4

• Increments counters for any files owned by the parent, to reflect that an additional process now also owns those files

5•Assigns the child process to the Ready to Run state

6

•Returns the ID number of the child to the parent process, and a 0 value to the child process

Page 61: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

• After creating the process the Kernel can do one of the following, as part of the dispatcher routine:

– stay in the parent process

– transfer control to the child process

– transfer control to another process

Page 62: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating

Summary The most fundamental concept in a modern OS is the process

The principal function of the OS is to create, manage, and terminate processes

Process control block contains all of the information that is required for the OS to manage the process, including its current state, resources allocated to it, priority, and other relevant data

The most important states are Ready, Running and Blocked

The running process is the one that is currently being executed by the processor

A blocked process is waiting for the completion of some event

A running process is interrupted either by an interrupt or by executing a supervisor call to the OS

Page 63: Operating Systems William Stallings - kennisbanksu.comkennisbanksu.com/wp-content/uploads/2016/03/Hoofdstuk-3-Operating... · William Stallings Cluster Apple unix Windows Operating