Operating System Objectives and Functions

advertisement
CmSc 335 Operating Systems
Chapter 2: OS Overview
1. Operating system objectives and functions
Operating systems control and support the usage of computer systems.
a. usage
users of a computer system:
programs - use memory, use CPU time, use I/O devices
human users
programmers - use program development tools such as debuggers, editors
end users - use application programs, e.g. Internet explorer
b. computer system = hardware + software
OS is a part of the computer software, it is a program. It is a very special program, that is
the first to be executed when the computer is switched on, and is supposed to control and
support the execution of other programs and the overall usage of the computer system.
c. control
The operating system controls the usage of the computer resources - hardware devices
and software utilities. We can think of an operating system as a Resource Manager. Here
are some of the resources managed by the OS:
Processors,
Main memory,
Secondary Memory,
Peripheral devices,
Information.
d. support
The operating system provides a number of services to assist the users of the computer
system:
For the programmers:
Utilities - debuggers, editors, file management, etc.
For the end users - provides the interface to the application programs
For programs - loads instructions and data into memory, prepares I/O devises for
usage, handles interrupts and error conditions.
The hierarchical view of the computer system illustrates how the operating system interacts with
the users of the computer system:
1
Main Objectives in OS design:
Convenience – makes computer user friendly.
Efficiency- allows computer to use resources efficiently.
Ability to evolve- constructed in a way to permit effective development, testing and
introduction of new functions without interfering with service.
2. Evolution of Operating Systems
Serial Processing - 1940’s – 1950’s programmer interacted directly with hardware. No
operating system.
problems
Scheduling - users sign up for machine time. Wasted computing time
Setup Time- Setup included loading the compiler, source program, saving
compiled program, and loading and linking. If an error occurred - start over.
2
Simple Batch Systems
Improve the utilization of computers.
Jobs were submitted on cards or tape to an operator who batches jobs together
sequentially. The program that controls the execution of the jobs was called monitor - a simple
version of an operating system. The interface to the monitor was accomplished through Job
Control Language (JCL). For example, a JCL request could be to run the compiler for a
particular programming language, then to link and load the program, then to run the user
program.
Hardware features:
Memory protection: do not allow the memory area containing the monitor to be altered
Timer: prevents a job from monopolizing the system
Problems:
Bad utilization of CPU time - the processor stays idle while I/O devices are in use.
Multiprogrammed Batch Systems
More than one program resides in the main memory. While a program A uses an I/O device the
processor does not stay idle, instead it runs another program B.
3
New features:
Memory management - to have several jobs ready to run, they must be kept in main
memory
Job scheduling - the processor must decide which program to run.
Time-Sharing Systems
Multiprogramming systems : several programs use the computer system
Time-sharing systems : several (human) users use the computer system interactively.
Characteristics:
 Using multiprogramming to handle multiple interactive jobs
 Processor’s time is shared among multiple users
 Multiple users simultaneously access the system through terminals
Batch Multiprogramming
Time Sharing
Principal objective
Maximize processor use
Minimize response time
Source of directives to
operating system
Job control language commands
provided with the job
Commands entered at the
terminal
Time sharing is multiprogramming. The key differences between time-sharing systems and batch
multiprogramming systems are given in the table above.
3. Major Achievements
Five major theoretical advances in development
Processes
Memory Management
Information protection and security
Scheduling and resource management
System structure
4
3.1. Processes
What is a process?
A program in execution
An instance of a program running on a computer
The entity that can be assigned to and executed on a processor
A unit of activity characterized by a single sequential thread of execution, a current state,
and an associated set of system resources
Difficulties with designing system software:
Improper Synchronization: results from an improper design of a signaling mechanism can
result in duplicate signals, or lost signals.
Failed Mutual Exclusion: two programs attempt to modify shared piece of data.
Nondeterministic program operation: a program may change the contents of memory used by
another program, and in this way affect unpredictably the operation of the other program.
Deadlock: each program is waiting for the other program to release its resource
Solution to these problems: use the concept of a process that consists of
An executable program
Associated data needed by the program
Execution context of the program: The entire state of the process at any instant is contained
in its context. All information the operating system needs to manage the process:
Contents of process registers
Information about priority of the process
Whether the process is waiting for an I/O event
etc
5
3.2. Memory Management
Responsibilities of OS
Process isolation - prevent independent processes from interfering with each other
Automatic allocation and management - transparent to the programmer
Support of modular programming
Protection and access control
Long-Term Storage
The above requirements are satisfied by means of virtual memory and file system facilities
6
Virtual memory and paging
 Allows programmers to address memory from a logical point of view
 Allows process to be comprised of a number of fixed-size blocks, called pages
 Virtual address is a page number and an offset within the page
 Each page may be located anywhere in main memory
 Dynamic mapping between the virtual address used in the program and the real address in
main memory
File system
Implements long-term store
Information stored in named objects called files
3.3. Information protection and security
Controlling access to computer systems and the information stored in them
 Availability: Concerned with protecting the system against interruption.
 Confidentiality: Assures that users cannot read data for which access is unauthorized.
 Data integrity: Protection of data from unauthorized modification.
 Authenticity: Concerned with the proper verification of the identity of users.
3.4. Scheduling and resource management
Factors to be considered:
Fairness- give equal and fair access to all jobs of the same class
Differential Responsiveness- discriminate between different classes of jobs.
Efficiency- maximize throughput, minimize response time and accommodate as many users as
possible.
The major elements of the operating system involved in scheduling and resource management in
a multiprogramming environment are depicted in Figure 2.11
I/O queues: processes waiting for I/O devices ( a queue is associated with each I/O
device)
Short-term queue: a list of processes whose execution has been started. They reside in
main memory. Round-robin technique: give each process some time in turn.
Long-term queue: a list of new jobs waiting to be started.
How does it work?
Assume that a process is running. The following events transfer the control from the
process to the OS
Service call from the process - the process explicitly invokes some of the OS
services, e.g. I/O operations.
Interrupt from the process, e.g. exception handling
Timer interrupt - the time slice for the process is over
7
I/O interrupt - an I/O device reports its status to the OS.
In each case the corresponding handler is invoked, and then the short-term scheduler
picks up the next process to be run.
8
4. Characteristics of Modern Operating Systems
Microkernel architecture-assigns only a few essential functions to the kernel, including address
spaces, interprocess communication, and basic scheduling.
Multithreading- the process is divided into threads that can run simultaneously
Thread- dispatchable unit of work. It includes a processor context program counter and
stack pointer and its own data storage for the stack. It executes sequentially and is interruptable
Process- collection of one or more threads and associated system resources.
Symmetric multiprocessing- stand-alone computer with multiple processors that share the same
memory and I/O facilities connected by a communication bus. All processors can perform the
same functions
9
Distributed operating systems - provide the illusion of a single main memory and single
secondary memory space. Used for distributed file system
Object-oriented design - used for adding modular extensions to a small kernel.
Enables programmers to customize an operating system without disrupting system integrity
10
Exam-like questions:
1. Compare batch multiprogramming systems and time-sharing systems. Discuss their
similarities and differences.
2. How is a process defined?
3. Discuss the difficulties in early OS that motivated the use of processes in OS design.
4. Describe briefly virtual memory and paging techniques for memory management.
5. Describe briefly how the resource scheduling works.
6. List and describe briefly four of the characteristics of modern operating systems
11
Download