35
Operating System Organization

Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

  • View
    229

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Operating SystemOrganization

Page 2: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Purpose of an OS

The Abstractions

Create the Abstractions

Coordinate Useof the AbstractionsProcesses

Page 3: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Process –What are involved ?

• All of the information needed to keep track of a process when switching is kept in a data package called a process control block.

Page 4: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

The process control block typically contains:

• An ID number that identifies the process

• Pointers to the locations in the program and its data where processing last occurred

• Register contents

• States of various flags and switches

Page 5: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

More …

• Pointers to the upper and lower bounds of the memory required for the process

• A list of files opened by the process

• The priority of the process

• The status of all I/O devices needed by the process

Page 6: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Thrashing • This process swapping happens without direct

user interference, and each process gets enough CPU cycles to accomplish its task in a reasonable amount of time.

• Trouble can come, though, if the user tries to have too many processes functioning at the same time.

• The operating system itself requires some CPU cycles to perform the saving and swapping of all the registers, queues and stacks of the application processes.

Page 7: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Thrashing

• If enough processes are started, and if the operating system hasn't been carefully designed, the system can begin to use the vast majority of its available CPU cycles to swap between processes rather than run processes.

• When this happens, it's called thrashing, and it usually requires some sort of direct user intervention to stop processes and bring order back to the system.

Page 8: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Thrashing

• When referring to a computer, "thrashing" or "disk thrashing" is a term used to describe when the hard disk drive is being overworked by moving information between the system memory and virtual memory excessively.

• Thrashing is often caused when the system does not have enough memory, the system swap file is not properly configured, and/or to much is running on the computer and it has low system resources.

Page 9: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Thrashing

• When thrashing occurs a user will notice the computer hard disk drive always working - a decrease in system performance.

• Thrashing is bad on a hard disk drive because of the amount of work the hard disk drive has to do and if is left unfixed will likely cause an early failure of the hard disk drive.

Page 10: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Resolve hard disk drive thrashing

• Increase the amount of RAM in the computer.

• Decrease the amount of programs being ran on the computer.

• Adjust the size of the swap file.

Page 11: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Swap Files

• A file stored on the computer hard disk drive that is used as a temporary location to store information that is not currently being used by the computer RAM.

• By using a swap file a computer has the ability to use more memory then what is physically installed in the computer.

• However, users who are low on hard disk space may notice that the computer runs slower because of the inability of the swap file to grow in size. 

Page 12: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Swap Files

• OS Swap File Name

• Windows 95 / 98 / ME WIN386.SWP

• Windows NT / 2000 / XP PAGEFILE.SYS

Page 13: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

OS Requirements

• Provide resource abstractions

Process abstraction of CPU/memory use Address space Thread abstraction of CPU within address space

Resource abstraction “Anything a process can request that can block the process if it

is unavailable” NT uses “object abstraction” to reference resources

File abstraction of secondary storage use

Page 14: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

DOS -- Resource Abstraction Only

Processor(s) Main Memory Devices

ProgramProgram

ProgramProgram

ProgramProgram

OS ServicesOS Services

LibrariesLibraries

ROM RoutinesROM Routines

Page 15: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

OS Requirements (cont)

• Provide resource abstractions

• Manage resource sharing– Time/space-multiplexing– Exclusive use of a resource– Isolation– Managed sharing

Page 16: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Abstraction & Sharing

Processor(s) Main Memory Devices

LibrariesLibraries

ROM RoutinesROM Routines

ProgramProgramStateState

Process

ProgramProgramStateState

Process

ProgramProgramStateState

Process

OS Services • Abstraction• Manage sharing

Page 17: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

OS Design Constraints• Performance

• Protection and security

• Correctness

• Maintainability

• Commercial factors

• Standards and open systems

Page 18: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Performance

• The OS is an overhead function should not use too much of machine’s resources

• Minimum functionality is to implement abstractions

• Additional function must be traded off against performance– DOS: one process– UNIX: low level file system

Page 19: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Protection & Security

• Multiprogramming resource sharing

• Therefore, need software-controlled resource isolation

• Security policy: Sharing strategy chosen by computer’s owner

• Protection mechanism: Tool to implement a family of security policies

Page 20: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Correctness & Maintainability

• Security depends on correct operation of software trusted vs untrusted software

• Maintainability relates to ability of software to be changed

• If either is sufficiently important, can limit the function of the OS– Guiding a manned spaceship– Managing a nuclear reactor

Page 21: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Device Management

Device-IndependentPart

Device-IndependentPart

Device-DependentPart

Device-DependentPart

Device …Device Device

Device-DependentPart

Device-DependentPart

Device-DependentPart

Device-DependentPart

Page 22: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Process, Thread, and Resource Management

…Processor

PrimaryMemory

AbstractResources

MultiprogrammingMultiprogramming

ThreadAbstraction

ThreadAbstraction

ProcessAbstraction

ProcessAbstraction Generic

ResourceManager

GenericResourceManager

OtherOther

Page 23: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Memory Management

PrimaryMemory

ProcessManager

ProcessManager

BlockAllocation

BlockAllocation

VirtualMemory

VirtualMemory

Isolation &Sharing

Isolation &Sharing

StorageDevices

Page 24: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Exclusive Access to a Resource

Process AProcess A

SupervisorProgram

SupervisorProgram

A’s ProtectedObject

A’s ProtectedObject

Processor

Process BProcess B

Page 25: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Processor Modes

• Mode bit: Supervisor or User mode

• Supervisor mode– Can execute all machine instructions– Can reference all memory locations

• User mode– Can only execute a subset of instructions– Can only reference a subset of memory

locations

Page 26: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Kernels

• The part of the OS critical to correct operation (trusted software)

• Executes in supervisor mode

• The trap instruction is used to switch from user to supervisor mode, entering the OS

Page 27: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Supervisor and User Memory

UserSpace

UserSpace

SupervisorSpace

SupervisorSpace

UserProcess

UserProcess

SupervisorProcess

SupervisorProcess

Page 28: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Procedure Call and Message Passing Operating Systems

call(…);

trap

return;

send(…, A, …);receive(…, B, …);

receive(…A, …); …send(…, B, …);

send/receive

Page 29: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

System Call Using the trap Instruction

…fork();…

fork() {…trap N_SYS_FORK()…}

sys_fork()

sys_fork() {/* system function */ … return;}

KernelTrap Table

Page 30: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

A Thread Performing a System Call

User Space Kernel Space

fork();

sys_fork() {

}

Thread

Page 31: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Basic Operating System Organization

Processor(s) Main Memory Devices

Process, Thread &Resource Manager

MemoryManager

DeviceManager

FileManager

Page 32: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

LibrariesLibraries CommandsCommands

Device DriverDevice Driver

The UNIX ArchitectureInteractive User

ApplicationPrograms

ApplicationPrograms

OS System Call Interface

Device DriverDevice Driver

Device DriverDevice Driver

Dri

ver

Inte

rfac

eD

rive

r In

terf

ace

…Monolithic Kernel Module•Process Management•Memory Management•File Management•Device Mgmt Infrastructure

Trap Table

Page 33: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Microkernel Organization

Device DriversDevice DriversMicrokernelMicrokernel

Processor(s) Main Memory Devices

LibrariesLibraries

ProcessProcess

ProcessProcess

ProcessProcess

ServerServer ServerServer ServerServer

User

Supervisor

Page 34: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Windows NT Organization

Processor(s) Main Memory Devices

LibrariesLibraries

ProcessProcess

ProcessProcess

ProcessProcess

SubsystemSubsystemUser

Supervisor

SubsystemSubsystem SubsystemSubsystem

Hardware Abstraction LayerHardware Abstraction LayerNT Kernel

NT ExecutiveI/O SubsystemI/O Subsystem

TT

TT

TT T T

T

Process ManagementMemory ManagementFile ManagementDevice Mgmt Infrastructure

Page 35: Operating System Organization. Purpose of an OS The Abstractions Create the Abstractions Coordinate Use of the Abstractions Processes

Monitoring the Kernel

Processor(s) Main Memory Devices

LibrariesLibraries

ProcessProcess

ProcessProcess

ProcessProcess

SubsystemSubsystem SubsystemSubsystem SubsystemSubsystem

Hardware Abstraction LayerHardware Abstraction LayerNT Kernel

NT ExecutiveI/O SubsystemI/O Subsystem

TT

TT

TT T T

TTaskManager

pview

pstat

Supervisor

User