Processes - Advanced Operating System - Lecture Slides, Slides of Computer Science

These are the lecture Slides of Advanced Operating System which includes Virtual Memory Performance, Resident Set Management, Allocating Pages, Page Fault Frequency Algorithm, Working Set Strategy, Thrashing, Replacement Policy, Multiprogramming Level etc. Key important points are: Processes, Modes of Execution, Typical Functions, Memory Management, Support Functions, Remote Procedure Calls, File Sharing, Multiple Processes, Sharing System, Process Creation, Process Termination

Typology: Slides

2012/2013

Uploaded on 03/20/2013

dharmaketu
dharmaketu šŸ‡®šŸ‡³

4.6

(165)

99 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
1
Processes
Processes
COMP755
COMP755
Advanced Operating Systems
Advanced Operating Systems
2
2
OS Structure
OS Structure
An OS has many parts.
An OS has many parts.
The Kernel is the core of the OS. It
The Kernel is the core of the OS. It
controls the execution of the system.
controls the execution of the system.
Many OS features run outside of the
Many OS features run outside of the
kernel, such as the shell.
kernel, such as the shell.
3
3
OS Structure
OS Structure
4
4
Modes of Execution
Modes of Execution
Kernel Mode
– more privileged mode
– has complete control of the processor and all
its instructions, registers, and memory
– not desirable for user programs
User Mode
– less privileged mode
– user program typically execute in this mode
– parts of the OS run in this mode
5
5
Typical Functions of an
OS Kernel
Process Management
Memory Management
I/O Management
Support Functions
6
6
Non
Non-
-Kernel OS
Kernel OS
Shell
Shell –
–user interface to the OS. In
user interface to the OS. In
Microsoft Windows, this is called the
Microsoft Windows, this is called the
Explorer
Explorer (not the Internet Explorer)
(not the Internet Explorer).
.
File Sharing
File Sharing
Remote Procedure Calls
Remote Procedure Calls
Utilities
Utilities
Docsity.com
pf3
pf4
pf5

Partial preview of the text

Download Processes - Advanced Operating System - Lecture Slides and more Slides Computer Science in PDF only on Docsity!

11

ProcessesProcesses

COMP755COMP

Advanced Operating SystemsAdvanced Operating Systems

22

OS StructureOS Structure

An OS has many parts. An OS has many parts. The Kernel is the core of the OS. It The Kernel is the core of the OS. It controls the execution of the system.controls the execution of the system. Many OS features run outside of the Many OS features run outside of the kernel, such as the shell.kernel, such as the shell.

33

OS StructureOS Structure

44

Modes of ExecutionModes of Execution

Kernel Mode

  • more privileged mode
  • has complete control of the processor and all its instructions, registers, and memory
  • not desirable for user programs User Mode
  • less privileged mode
  • user program typically execute in this mode
  • parts of the OS run in this mode

55

Typical Functions of an

OS Kernel

Process Management

Memory Management I/O Management

Support Functions

66

Non-Non-Kernel OSKernel OS

Shell – Shell– user interface to the OS. Inuser interface to the OS. In Microsoft Windows, this is called theMicrosoft Windows, this is called the ExplorerExplorer (not the Internet Explorer)(not the Internet Explorer) .. File Sharing File Sharing Remote Procedure Calls Remote Procedure Calls

Utilities Utilities

77

The ProcessThe Process

  • • (^) All multiprogrammingAll multiprogramming OSsOSs are built aroundare built around the concept of processes.the concept of processes.
  • • A process is something akin to a program.A process is something akin to a program.
  • • (^) Some programs have multiple processesSome programs have multiple processes and the OS has several processes.and the OS has several processes.
  • • A process has:A process has:
    • • memorymemory
    • • ability to use the CPU (a thread)ability to use the CPU (a thread)
    • • resources allocated to itresources allocated to it 88

Multiple ProcessesMultiple Processes

There are usually many processes existing There are usually many processes existing in the system.in the system. If there is only one CPU, then only one If there is only one CPU, then only one process can be running at any one time.process can be running at any one time. Other processes might be waiting to run. Other processes might be waiting to run. Some (most) processes will be blocked Some (most) processes will be blocked waiting for something to happen (i.e. I/O)waiting for something to happen (i.e. I/O)

99

Sharing the SystemSharing the System

Most programs perform a lot of I/O andMost programs perform a lot of I/O and therefore spend a lot of time waiting for I/Otherefore spend a lot of time waiting for I/O to complete.to complete. When a program is waiting for I/O, anotherWhen a program is waiting for I/O, another program can be running.program can be running. Some programs wait for a very long timeSome programs wait for a very long time for input (such as input from a keyboard,for input (such as input from a keyboard, mouse or network)mouse or network)

1010

ā€œFrom a programmer's point of ā€œFrom a programmer's point of view, the user is a peripheral thatview, the user is a peripheral that types when you issue a readtypes when you issue a read request.ā€request.ā€

  • P. Williams-P. Williams

1111

Process CreationProcess Creation

  • • When a process is created, the OSWhen a process is created, the OS
    • – Builds the data structures that are used toBuilds the data structures that are used to manage the processmanage the process
    • – Allocates address space in main memory to theAllocates address space in main memory to the processprocess
  • • (^) When does a process get created?When does a process get created?
    • – When a program is startedWhen a program is started
    • – Created by OS to provide a service to a userCreated by OS to provide a service to a user (ex: printing a file)(ex: printing a file)
    • – Spawned by an existing processSpawned by an existing process 1212

Process TerminationProcess Termination

  • • User quits an application (e.g. wordUser quits an application (e.g. word processor)processor)
  • • Task completesTask completes
  • • Error and fault conditionsError and fault conditions

1919

Queuing ModelQueuing Model Multiple Blocked QueuesMultiple Blocked Queues

2020

DispatcherDispatcher

A part of the OS that gives the processor from one process to another Selects a process from the queue to execute after interrupt or process termination Prevents a single process from monopolizing the processor time

2121

Context SwitchContext Switch

When CPU switches to another process,When CPU switches to another process, the system must save the state of the oldthe system must save the state of the old process and load the saved state for theprocess and load the saved state for the new processnew process

ContextContext--switch time is overhead; theswitch time is overhead; the system does no useful work whilesystem does no useful work while switchingswitching

Time dependent on hardware supportTime dependent on hardware support

2222

Operating System Control StructuresOperating System Control Structures

  • • An OS maintains several tables forAn OS maintains several tables for managing processes and resources:managing processes and resources: - • Memory tablesMemory tables - • I/O tablesI/O tables - • File tablesFile tables - •^ Process tablesProcess tables

2323

Process Control StructuresProcess Control Structures

  • Process image: the collection of program, data and attributes (process control block)
  • Process control block: the collection of attributes of the process that are used by OS for process control

2424

Process Control Block (PCB)Process Control Block (PCB)

  • • (^) Process Identification InformationProcess Identification Information
    • – Processor Identifier (PID)Processor Identifier (PID) 16 bit integer unique for each process 16 bit integer unique for each process
    • – PID of the parent processPID of the parent process
    • – User identifierUser identifier
      • who is responsible for the job

2525

PCB ContentsPCB Contents

  • • CPU State InformationCPU State Information
    • – What the CPU needs to run thisWhat the CPU needs to run this process.process.
    • – UserUser--visible registersvisible registers
    • – Program CounterProgram Counter
    • – PSWPSW
    • – Stack pointersStack pointers

2626

PCB ContentsPCB Contents

  • • Scheduling and state informationScheduling and state information
    • Process state–Process state
    • priority–priority
    • event for which the process is waiting (if–event for which the process is waiting (if blocked)blocked)
  • • Process relationshipsProcess relationships
    • may hold pointers to other PCBs for–may hold pointers to other PCBs for process queues, parent-process queues, parent-child relationshipschild relationships and other structuresand other structures

2727

PCB ContentsPCB Contents

  • • InterInter--process communication (IPC)process communication (IPC)
    • – may hold flags and signals for IPCmay hold flags and signals for IPC
  • •^ Process privilegesProcess privileges
  • •^ Memory managementMemory management
    • – pointers to segment/page tables assigned topointers to segment/page tables assigned to this processthis process
  • • Resource ownership and utilizationResource ownership and utilization
    • – resources in use: opened files, I/O devicesresources in use: opened files, I/O devices

2828

Process CreationProcess Creation

Assign a unique Processor ID (PID). Assign a unique Processor ID (PID). Allocate RAM for the PCB Allocate RAM for the PCB Initialize the PCB Initialize the PCB Allocate RAM for the program (code, data, Allocate RAM for the program (code, data, stack and heap)stack and heap) Copy the program into the RAM Copy the program into the RAM Put the PCB on the list of PCBs Put the PCB on the list of PCBs

2929

Creating a new ProcessCreating a new Process

In C or C++, you can create a newIn C or C++, you can create a new process with the fork functionprocess with the fork function int fork();int fork(); When fork is called, the RAM of theWhen fork is called, the RAM of the program is copied to another location isprogram is copied to another location is RAM. A new process is created to run inRAM. A new process is created to run in the new program address space. The newthe new program address space. The new process is put on the ready list.process is put on the ready list.

3030

fork functionfork function

The return value of the fork function is: The return value of the fork function is: -1 = Error - 1 = Error 0 = This is the process that was just0 = This is the process that was just created.created. number = This process is the parent thatnumber = This process is the parent that just executed the fork function. Thejust executed the fork function. The number returned is the PID of the childnumber returned is the PID of the child process.process.

3737

shmctlshmctl

Shared memory control function can beShared memory control function can be used to delete a shared memory segment.used to delete a shared memory segment. shmctl(shared_id, IPC_RMID, NULL);

shared_idshared_id is the return value fromis the return value from shmgetshmget..

IPC_RMID is the function code to delete aIPC_RMID is the function code to delete a shared segment.shared segment.

3838

Programming NoteProgramming Note

Shared memory segments are permanent Shared memory segments are permanent data structures. They do NOT go awaydata structures. They do NOT go away when the program terminates.when the program terminates. Be sure to delete any and all shared Be sure to delete any and all shared memory segments you create.memory segments you create.

3939

Multiple Process ConflictsMultiple Process Conflicts

A process or thread can be halted at anyA process or thread can be halted at any time by the OS to run another process ortime by the OS to run another process or thread.thread.

4040

X++ in Machine LanguageX++ in Machine Language

LOADLOAD R1,XR1,X ADDADD R1,1R1, OS switches to another processOS switches to another process LOADLOAD R1,XR1,X ADDADD R1,1R1, STORE R1,XSTORE R1,X OS switches to another processOS switches to another process STORE R1,XSTORE R1,X