Download Week-3

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Acorn MOS wikipedia , lookup

Mobile operating system wikipedia , lookup

Library (computing) wikipedia , lookup

Berkeley Software Distribution wikipedia , lookup

Plan 9 from Bell Labs wikipedia , lookup

RSTS/E wikipedia , lookup

Burroughs MCP wikipedia , lookup

Copland (operating system) wikipedia , lookup

DNIX wikipedia , lookup

Distributed operating system wikipedia , lookup

Process management (computing) wikipedia , lookup

Security-focused operating system wikipedia , lookup

Unix security wikipedia , lookup

Spring (operating system) wikipedia , lookup

CP/M wikipedia , lookup

VS/9 wikipedia , lookup

Transcript
Chapter 2:
Operating-System Structures
Operating System Concepts with Java – 8th Edition
2.1
Silberschatz, Galvin and Gagne ©2009
Standard C Library Example
 C program invoking printf() library call, which calls write() system call
Operating System Concepts with Java – 8th Edition
2.2
Silberschatz, Galvin and Gagne ©2009
System Call Parameter Passing
 Often, more information is required than simply identity of desired
system call

Exact type and amount of information vary according to OS and
call
 Three general methods used to pass parameters to the OS

Simplest: pass the parameters in registers
In some cases, may be more parameters than registers
 Parameters stored in a block, or table, in memory, and address of
block passed as a parameter in a register
 This approach taken by Linux and Solaris
 Parameters placed, or pushed, onto the stack by the program and
popped off the stack by the operating system


Block and stack methods do not limit the number or length of
parameters being passed
Operating System Concepts with Java – 8th Edition
2.3
Silberschatz, Galvin and Gagne ©2009
Parameter Passing via Table
Operating System Concepts with Java – 8th Edition
2.4
Silberschatz, Galvin and Gagne ©2009
Types of System Calls
 Process control
 File management
 Device management
 Information maintenance
 Communications
 Protection
Operating System Concepts with Java – 8th Edition
2.5
Silberschatz, Galvin and Gagne ©2009
Examples of Windows and Unix System Calls
Operating System Concepts with Java – 8th Edition
2.6
Silberschatz, Galvin and Gagne ©2009
Process Control Issues
 Loading and executing a program
 What
happens to the existing program?
Lost
Suspended
(saved and allowed to
continue later)
Run
concurrently (needs creation of new
process)
 Control execution of the new program (set
priority, set max execution time, terminate)
Operating System Concepts with Java – 8th Edition
2.7
Silberschatz, Galvin and Gagne ©2009
Process Control Issues (Contd.)
 Waiting for jobs
 wait
time, wait event and signal event
 Managing shared data
 acquire
lock, release lock, etc.
 Handling termination process (Normal or
abnormal)
 Taking
memory dump
 Return
control to calling process
Operating System Concepts with Java – 8th Edition
2.8
Silberschatz, Galvin and Gagne ©2009
MS-DOS execution
(a) At system startup (b) running a program
Operating System Concepts with Java – 8th Edition
2.9
Silberschatz, Galvin and Gagne ©2009
FreeBSD Running Multiple Programs
Operating System Concepts with Java – 8th Edition
2.10
Silberschatz, Galvin and Gagne ©2009
File Management Issues
 Creating files and directories
 Deleting files and directories
 Read and write
 Reposition
 Set attributes and get attributes
 Move and copy
 Some
OSes provide explicit system calls
 Others
provide API which is implemented
using other system calls
Operating System Concepts with Java – 8th Edition
2.11
Silberschatz, Galvin and Gagne ©2009
Device Management Issues
 Physical and virtual resources
 Request and release devices in multi-user
OS
 Needed
to ensure exclusive access to
devices
 Unmanaged
access can lead to device
contention and deadlocks
 Read, write, reposition
 Unix
treats devices as files
Operating System Concepts with Java – 8th Edition
2.12
Silberschatz, Galvin and Gagne ©2009
Information Management Issues
 Transferring information between OS and
user programs
 System time, date, information about users,
processes, resources etc.
 Tracing and debugging programs
 Dumping,
 Single
trace, etc.
step
 Profiling of programs
 Get and set of attributes of processes
Operating System Concepts with Java – 8th Edition
2.13
Silberschatz, Galvin and Gagne ©2009
Communication Issues
 Message passing model
 exchange
between processes on same
machine or different machine
 Needs opening of a connection
 Host name and process id
 Open, close, accept connections
 Daemon processes – waiting on incoming
connections
Operating System Concepts with Java – 8th Edition
2.14
Silberschatz, Galvin and Gagne ©2009
Shared Memory
 Shared memory create
 Shared memory attach
 Process inform OS that they want to remove
the OS placed restriction about accessing
each others memory
 Modalities of data sharing determined by the
processes and not the OS
Operating System Concepts with Java – 8th Edition
2.15
Silberschatz, Galvin and Gagne ©2009
System Programs
 System programs provide a convenient environment for program
development and execution. The can be divided into:

File manipulation

Status information

File modification

Programming language support

Program loading and execution

Communications

Application programs
 Most users’ view of the operation system is defined by system
programs, not the actual system calls
Operating System Concepts with Java – 8th Edition
2.16
Silberschatz, Galvin and Gagne ©2009
System Programs
 Provide a convenient environment for program development and
execution

Some of them are simply user interfaces to system calls; others are
considerably more complex
 File management - Create, delete, copy, rename, print, dump, list, and
generally manipulate files and directories
 Status information

Some ask the system for info - date, time, amount of available
memory, disk space, number of users

Others provide detailed performance, logging, and debugging
information

Typically, these programs format and print the output to the terminal
or other output devices

Some systems implement a registry - used to store and retrieve
configuration information
Operating System Concepts with Java – 8th Edition
2.17
Silberschatz, Galvin and Gagne ©2009
System Programs (Cont.)
 File modification

Text editors to create and modify files
 Special commands to search contents of files or perform
transformations of the text
 Programming-language support - Compilers, assemblers, debuggers
and interpreters sometimes provided
 Program loading and execution- Absolute loaders, relocatable loaders,
linkage editors, and overlay-loaders, debugging systems for higher-level
and machine language
 Communications - Provide the mechanism for creating virtual
connections among processes, users, and computer systems

Allow users to send messages to one another’s screens, browse
web pages, send electronic-mail messages, log in remotely, transfer
files from one machine to another
Operating System Concepts with Java – 8th Edition
2.18
Silberschatz, Galvin and Gagne ©2009
Operating System Design and Implementation
 Design and Implementation of OS not “solvable”, but
some approaches have proven successful
 Internal structure of different Operating Systems can
vary widely
 Start by defining goals and specifications
 User goals and System goals

User goals - Should be convenient to use, easy to learn,
reliable, safe, and fast

System goals - Should be easy to design, implement, and
maintain, as well as flexible, reliable, error-free, and efficient
 Affected by choice of hardware, type of system
Operating System Concepts with Java – 8th Edition
2.19
Silberschatz, Galvin and Gagne ©2009
Mechanism – Policy Separation
 Policy: What will be done?
 Mechanism: How to do it?
 Examples
attendance credit – card scanner/signup
sheet/roll call
 Class
 Time-multiplexing
 LRU
of CPU – Timer construct
– Linked list implementation
 The separation of policy from allows maximum
flexibility if policy decisions are to be changed later
 Solaris
Scheduler
Operating System Concepts with Java – 8th Edition
2.20
Silberschatz, Galvin and Gagne ©2009
OS Implementation
 Early OSes were written in assembly language
 Currently most OSes are written in C
 Advantages of using high-level language
 Faster, compact
 Easier to understand, debug and take advantage of
compiler optimizations
 Portable – MS DOS Vs. Unix
 Possible disadvantage?
 Performance
Operating System Concepts with Java – 8th Edition
2.21
Silberschatz, Galvin and Gagne ©2009
OS Structure
 Describes how the code of the OS is organized
 Function
call, information flow, etc.
 Not enough thought on structure in early OSes
 Heavy
price - crashes, vulnerabilities, etc.
 MS-DOS – written to provide the most
functionality in the least space
 Not
divided into modules
 Although
MS-DOS has some structure, its
interfaces and levels of functionality are not
well separated
Operating System Concepts with Java – 8th Edition
2.22
Silberschatz, Galvin and Gagne ©2009
MS-DOS Layer Structure
Operating System Concepts with Java – 8th Edition
2.23
Silberschatz, Galvin and Gagne ©2009
OS Structures (Contd.)
 Monolithic Kernel
 Layered Structure
 Micro-Kernel
 Modular Approach
Operating System Concepts with Java – 8th Edition
2.24
Silberschatz, Galvin and Gagne ©2009
Monolithic Kernel
 Approach followed by early UNIX
 Kernel and system programs
 Kernel is a collection of various sub-systems
 File
system
 CPU
Scheduling
 Memory
management
 Communications
 Very hard to maintain
 Especially
modifying or adding new
functionality
Operating System Concepts with Java – 8th Edition
2.25
Silberschatz, Galvin and Gagne ©2009
Traditional UNIX System Structure
Operating System Concepts with Java – 8th Edition
2.26
Silberschatz, Galvin and Gagne ©2009
Layered Approach
 OS built as a set of layers
 Bottom most layer is hardware
 Top most layer is user interface
 Each layer can invoke functionalities from layer
immediately below it
 Advantages



Easy debugging
Information hiding
Code modifications are relatively simple
 Drawbacks
 Placing routines in layers
 Less efficient – too many calls across layers and too
much data passing
Operating System Concepts with Java – 8th Edition
2.27
Silberschatz, Galvin and Gagne ©2009
Layered Operating System
Operating System Concepts with Java – 8th Edition
2.28
Silberschatz, Galvin and Gagne ©2009
Microkernel System Structure
 Mach OS by CMU to address problems with
monolithic kernel
 Moves as much from the kernel into “user” space
 Communication takes place between user
modules using message passing
 Benefits:




Easier to extend a microkernel
Easier to port the operating system to new architectures
More reliable (less code is running in kernel mode)
More secure
 Detriments:

Performance overhead of user space to kernel space
communication
Operating System Concepts with Java – 8th Edition
2.29
Silberschatz, Galvin and Gagne ©2009
Modules
 Modern OSes implement kernel modules

Uses object-oriented approach

Each core component is separate

Each talks to the others over known interfaces

Each is loadable as needed within the kernel

Features can be implemented dynamically
 Overall, similar to layers but with more
flexibility
Operating System Concepts with Java – 8th Edition
2.30
Silberschatz, Galvin and Gagne ©2009
Solaris Modular Approach
Operating System Concepts with Java – 8th Edition
2.31
Silberschatz, Galvin and Gagne ©2009
Hybrid Structure of Mac OS X
Operating System Concepts with Java – 8th Edition
2.32
Silberschatz, Galvin and Gagne ©2009
Virtual Machines
 VM technology takes layered approach to its
logical conclusion
 Pioneered by IBM CP/CMS in 1967
 Abstracts hardware resources into several
different executing environment

Each environment will be a separate machine
 A VM provides an interface identical to the
underlying bare hardware
 Guest process is an OS
 The operating system creates the illusion that it
has its own processor and (virtual memory).
Operating System Concepts with Java – 8th Edition
2.33
Silberschatz, Galvin and Gagne ©2009
Virtual Machines (Cont.)
(a) Nonvirtual machine (b) virtual machine
Operating System Concepts with Java – 8th Edition
2.34
Silberschatz, Galvin and Gagne ©2009
Virtual Machines Benefits
 Physical machine protected from VMs and
VMs protected from one another

Virus in a guest OS will not affect the host OS
 VMS can share files (through file system
volume)
 VMs can also communicate (via virtual network
interfaces)
 Aids in development and testing of OS
 Eliminates system development time
 Cloud computing and economies of scale
 Resource
optimization through consolidation
Operating System Concepts with Java – 8th Edition
2.35
Silberschatz, Galvin and Gagne ©2009
Virtual Machines Implementation
 Difficult to produce exact duplicate of the
underlying machine
 VM software can run in kernel mode. The VMs
should execute only in user mode
 Guest OSes also have user and kernel modes
 Virtual user mode – virtual kernel mode
transitions
 System calls cause transfer to VM monitor
 VM monitor changes the register contents
and program counter and transfer control
back to guest OS
 VMs can be slow
 VMs need some level of hardware support
Operating System Concepts with Java – 8th Edition
2.36
Silberschatz, Galvin and Gagne ©2009
Operating-System Debugging
 Debugging is finding and fixing errors, or bugs.
 OSes generate log files containing error information.
 Failure of an application can generate core dump file capturing
memory of the process.
 Operating system failure can generate crash dump file containing
kernel memory.
 Beyond crashes, performance tuning can optimize system
performance.
 Kernighan’s Law: “Debugging is twice as hard as writing the code in
the first place. Therefore, if you write the code as cleverly as possible,
you are, by definition, not smart enough to debug it.”
 DTrace tool in Solaris, FreeBSD, Mac OS X allows live instrumentation
on production systems.

Probes fire when code is executed, capturing state data and
sending it to consumers of those probes.
Operating System Concepts with Java – 8th Edition
2.37
Silberschatz, Galvin and Gagne ©2009
End of Chapter 2
Operating System Concepts with Java – 8th Edition
2.38
Silberschatz, Galvin and Gagne ©2009