View
229
Download
0
Tags:
Embed Size (px)
Citation preview
Operating SystemOrganization
Purpose of an OS
The Abstractions
Create the Abstractions
Coordinate Useof the AbstractionsProcesses
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.
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
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
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.
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.
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.
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.
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.
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.
Swap Files
• OS Swap File Name
• Windows 95 / 98 / ME WIN386.SWP
• Windows NT / 2000 / XP PAGEFILE.SYS
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
DOS -- Resource Abstraction Only
Processor(s) Main Memory Devices
ProgramProgram
ProgramProgram
ProgramProgram
OS ServicesOS Services
LibrariesLibraries
ROM RoutinesROM Routines
OS Requirements (cont)
• Provide resource abstractions
• Manage resource sharing– Time/space-multiplexing– Exclusive use of a resource– Isolation– Managed sharing
Abstraction & Sharing
Processor(s) Main Memory Devices
LibrariesLibraries
ROM RoutinesROM Routines
ProgramProgramStateState
Process
ProgramProgramStateState
Process
ProgramProgramStateState
Process
OS Services • Abstraction• Manage sharing
OS Design Constraints• Performance
• Protection and security
• Correctness
• Maintainability
• Commercial factors
• Standards and open systems
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
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
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
Device Management
Device-IndependentPart
Device-IndependentPart
Device-DependentPart
Device-DependentPart
Device …Device Device
Device-DependentPart
Device-DependentPart
Device-DependentPart
Device-DependentPart
Process, Thread, and Resource Management
…Processor
PrimaryMemory
AbstractResources
MultiprogrammingMultiprogramming
ThreadAbstraction
ThreadAbstraction
ProcessAbstraction
ProcessAbstraction Generic
ResourceManager
GenericResourceManager
OtherOther
Memory Management
PrimaryMemory
ProcessManager
ProcessManager
BlockAllocation
BlockAllocation
VirtualMemory
VirtualMemory
Isolation &Sharing
Isolation &Sharing
StorageDevices
Exclusive Access to a Resource
Process AProcess A
SupervisorProgram
SupervisorProgram
A’s ProtectedObject
A’s ProtectedObject
Processor
Process BProcess B
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
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
Supervisor and User Memory
UserSpace
UserSpace
SupervisorSpace
SupervisorSpace
UserProcess
UserProcess
SupervisorProcess
SupervisorProcess
Procedure Call and Message Passing Operating Systems
call(…);
trap
return;
send(…, A, …);receive(…, B, …);
receive(…A, …); …send(…, B, …);
send/receive
System Call Using the trap Instruction
…fork();…
fork() {…trap N_SYS_FORK()…}
sys_fork()
sys_fork() {/* system function */ … return;}
KernelTrap Table
A Thread Performing a System Call
User Space Kernel Space
fork();
sys_fork() {
}
Thread
Basic Operating System Organization
Processor(s) Main Memory Devices
Process, Thread &Resource Manager
MemoryManager
DeviceManager
FileManager
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
…
Microkernel Organization
Device DriversDevice DriversMicrokernelMicrokernel
Processor(s) Main Memory Devices
LibrariesLibraries
ProcessProcess
ProcessProcess
ProcessProcess
ServerServer ServerServer ServerServer
User
Supervisor
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
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