Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Computer Architecture OS 2

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 32

Computer Architecture And LO2

Operating Systems
Software Of The Computer
If a user wants to enter and run an application program, he/she needs a System Software.
System Software is a collection of programs that are executed as needed to perform tasks
such as:
1. Receiving and interpreting user commands
2. Entering and editing application programs and storing then as files in secondary storage
devices.
3. Running standard application programs such as word processors, spread sheets, games
etc.
Operating system - is key system software component which helps the user to exploit the
below underlying hardware with the programs.
How do users and processes interact
with the operating system?
Users interact indirectly through a collection of system programs that make up the
operating system interface.
The interface could be: A GUI, with icons and windows, etc.
A command-line interface for running processes and scripts, browsing files in
directories, etc.
Or, back in the olden days, a non-interactive batch system that takes a collection of
jobs, which it proceeds to churn through (e.g. payroll calculations, market predictions,
etc.) Processes interact by making system calls into the operating system proper (i.e.
the kernel).
Though we will see that, for stability, such calls are not direct calls to kernel functions.
OS Architecture With Services
MONOLITHIC SYSTEMS ARC
The core software components of an operating system are collectively known as
the kernel. The kernel has unrestricted access to all of the resources on the system.
In early monolithic systems, each component of the operating system was
contained within the kernel, could communicate directly with any other component,
and had unrestricted system access. While this made the operating system very
efficient, it also meant that errors were more difficult to isolate, and there was a
high risk of damage due to erroneous or malicious code.
MONOLITHIC SYSTEMS ARC
OS services

Typically, operating systems will offer the following services to processes:


1. Program execution: The system must be able to load a program into memory and to run
that program, end execution, either normally or abnormally (indicating error)
2. I/O operations: A running program may require I/O, which may involve a file or an I/O
device
3. File-system manipulation: Programs need to read and write files and directories, create
and delete them, search them, list file Information, permission management.
4. Interprocess Communication (IPC): Allowing processes to share data through message
passing or shared memory
OS services
5. Security –
The operating system uses password protection to protect user data and similar other
techniques. it also prevents unauthorized access to programs and user data.
6. Control over system performance – Monitors overall system health to help improve
performance. records the response time between service requests and system response to have
a complete view of the system health. This can help improve performance by providing
important information needed to troubleshoot problems.
7. Job accounting –
Operating system Keeps track of time and resources used by various tasks and users, this
information can be used to track resource usage for a particular user or group of user.
OS services
8. Error detecting aids –
Operating system constantly monitors the system to detect errors and avoid
the malfunctioning of computer system.
9. Coordination between other software and users –
Operating systems also coordinate and assign interpreters, compilers,
assemblers and other software to the various users of the computer systems.
SYSTEM CALLS
Programming interface to the services provided by the OS (e.g. open file, read file, etc.) Typically written
in a high-level language (C or C++) Mostly accessed by programs via a high-level Application Program
Interface (API) rather than direct system call.
Three most common APIs are Win32 API for Windows, POSIX API for UNIX-based systems (including
virtually all versions of UNIX, Linux, and Mac OS X) So why use APIs in user processes rather than system
calls directly?
System calls
provided by
Windows
and Linux
An
example of
a system
call
Trapping to the Kernel
The user process calls the system call wrapper function from the standard C library
The wrapper function issues a low-level trap instruction (in assembly) to switch from
user mode to kernel mode.

 A trap usually results in a switch to kernel mode, wherein the operating system
performs some action before returning control to the originating process.
Trapping to the Kernel
To get around the problem that no call can directly be made from user space to a specific
function in kernel space:

• Before issuing the trap instruction, an index is stored in a well known location (e.g. CPU
register, the stack, etc.).

• Then, once switched into kernel space, the index is used to look up the desired kernel
service function, which is then called.

 Some function calls may take arguments, which may be passed as pointers to structures
via registers.
Trapping to the Kernel
OS Design
An OS is possibly the most complex system that a computer will run, and it not yet clear (nor
may it ever be) how to design an operating system to best meet the many and varied
requirements placed on it.
The internal structure of OSes can vary widely.
We can start by defining goals and specifications:

 Affected by choice of hardware, type of system


 User goals and System goals
• User goals - operating system should be convenient to use, easy to learn, reliable, safe, and fast
• System goals - operating system should be easy to design, implement, and maintain, as well as
flexible, reliable, error-free, easy to extend, and efficient.
OS architectures have evolved over the years, generally trying to better balance efficiency
and stability
Separation of Policies And Mechanisms
Policy: What will be done?
Mechanism: How to do it?
The separation of policy from mechanism is a very important principle, it allows
maximum flexibility if policy decisions are to be changed later.
MS-DOS STRUCTURE
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 - the
highest layer is allowed to call the lowest layer.
So, it was easy for a user process (accidentally or on
purpose) to de-stabilise the whole system, which is
often what happened, even up until MS-DOS based
Windows ME
Strict Layered structure
The operating system is divided into a number of layers (levels), each built on top of
lower layers.
The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface.
With modularity, layers are selected such that each uses functions (operations) and
services of only lower-level layers
 Importantly for stability, modern CPUs offer protected mode, which means transition
between layers is controlled by hardware
 Attempts of software to run instructions or access memory regions that are higher privilege
will result in the CPU raising a hardware exception (e.g. divide by zero, attempt to access
hardware directly, etc.)
Strict Layered structure
Lends itself to simpler construction, since layers have well-defined functionality and
can be tested independently or altered with minimal impact on the rest of the OS (e.g.
lowest level could be adapted to different CPU architectures with minimal impact on
higher layers)
Consider a file system. The actual file-system can be implemented in a layer above a
layer that reads and writes raw data to a particular disk device, such that the file
system will work with any device implemented by the lower layer (e.g. USB storage
device, floppy disk, hard disk, etc.).
In practice, however, it can be difficult to decide how many layers to have and what to
put in each layer to build a general purpose operating system.
Strict Layered structure
Traditional UNIX structure

UNIX - one big kernel


 Consists of everything below the system-call interface and above the physical
hardware
 Provides the file system, CPU scheduling, memory management, and other
operating-system functions; a large number of functions for one level
 Limited to hardware support compiled into the kernel.
Traditional UNIX
Modular Kernel structure
Most modern operating systems implement kernel modules
• Uses object-oriented–like approach

• Each core component is separate

• Each talks to the others over known interfaces

• Each is loadable as needed within the kernel, so you could download a new device
driver for your OS and load it at run-time, or perhaps when a device is plugged in.
Modular Kernel structure
Overall, similar to layered architecture but with more flexibility, since all require
drivers or kernel functionality need not be compiled into the kernel binary.

Note that the separation of the modules is still only logical, since all kernel code
(including dynamically loaded modules) runs in the same privileged address space (a
design now referred to as monolithic), so I could write a module that wipes out the
operating system no problem.
This leads to the benefits of micro-kernel architecture, which we will look at soon
Modular Kernel
Functions Of An Operating
System
Following are some of important functions of an operating System.
 Memory Management
 Processor Management
 Device Management
 File Management
 Security
 Control over system performance
 Job accounting
 Error detecting aids
 Coordination between other software and users
Memory Management
The operating system manages the Primary Memory or Main Memory.
Main memory is made up of a large array of bytes or words where each byte or word
is assigned a certain address.
Main memory is a fast storage and it can be accessed directly by the CPU.
For a program to be executed, it should be first loaded in the main memory.
An Operating System performs the following activities for memory management:
It keeps tracks of primary memory, i.e., which bytes of memory are used by which
user program.
Memory Management
The memory addresses that have already been allocated and the memory addresses
of the memory that has not yet been used.

In multi programming, the OS decides the order in which process are granted access
to memory, and for how long.

It Allocates the memory to a process when the process requests it and deallocates
the memory when the process has terminated or is performing an I/O operation.
Processor Management
In a multi programming environment, the OS decides the order in which processes have
access to the processor, and how much processing time each process has.
This function of OS is called process scheduling.
An Operating System performs the following activities for processor management.
Keeps tracks of the status of processes.
The program which perform this task is known as traffic controller.
 Allocates the CPU that is processor to a process. De-allocates processor when a process
is no more required.
Device Management
An OS manages device communication via their respective drivers.
 It performs the following activities for device management.
Keeps tracks of all devices connected to system.
Designates a program responsible for every device known as the Input/Output
controller.
Decides which process gets access to a certain device and for how long.
Allocates devices in an effective and efficient way.
De-allocates devices when they are no longer required.
File Management

A file system is organized into directories for efficient or easy navigation and usage.

These directories may contain other directories and other files.

 An Operating System carries out the following file management activities.

It keeps track of where information is stored, user access settings and status of
every file and more… These facilities are collectively known as the file system.

You might also like