Professional Documents
Culture Documents
Polytechnic University of The Philippines Lopez Quezon, Branch
Polytechnic University of The Philippines Lopez Quezon, Branch
Contents
Lesson 1
2.1 Introduction
2.2 Computer System Structure
2.3 Computer Operation through the OS
2.3.1 Hardware Protection
2.3.2 I/O Protection
2.3.3 Memory Protection
2.3.4 CPU Protection
2.4 OS Components
2.4.1 Resource
2.4.2 Description of the Components of OS
Lesson 2
2.5 System Calls and Interrupts
2.5.1 Most Common Classes of Interrupts
2.5.2 Different Types of Systems Calls
Lesson 3
2.6 Common OS Structures
2.6.1 Simple Structures, early monolithic Unix Structure
2.6.2 Layered Approach
2.6.3 MicroKernel
2.6.4 Other Structures
2.7 Loading the Operating System
Learning Objectives:
• Identify the computer structure and the different operating system components;
• Know the different types of interrupts and the system calls;
• Describe the services an operating system provides to users processes and other
systems;
• Determine the different operating system structures; and
• Define new terminologies and discuss how operating system is loaded in the computer.
1
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
2.1 Introduction
An operating system provides the environment within which programs are executed.
Internally, operating systems vary greatly in their markup, since they are organized along many
different lines. The design of a new operating system is a major task, It is important that the goals
of the system be well defined before design begins. These goals form the basis for choices among
various algorithms and strategies.
We can view an operating system from several vantage points. One view focuses on the
services that the system provides; another, on the interface that it makes available to users and
programmers; a third, on its components and their interconnections. In this module, we explore
all three aspects of operating systems, showing the view points of users, programmers, and
operating system designers. We consider what services an operating system provides, how they
are provided, how they are debugged, and what the various methodologies are for designing such
systems. Finally, we describe how operating systems are created and how a computer starts its
operating system.
Figure 1.0 on the next page shows the different components of the computer. These
components are physically connected using a system bus which is a set of parallel wires attached
together that carries several bits at a time. There are three basic buses used in linking the different
components: the data bus, address bus and the control bus.
Notice that each of the peripheral devices makes use of an interface which translates
internal codes in the form of electronic pulses coming from the bus to an external code using
binary code which is understood by the specific peripheral device.
Communication between components is done through the system bus using electronic
pulses. The number of bits that passes through the bus depends on the size of the bus or the
so-called word size. To illustrate, a 64-bit computer means that the processor manipulates 64-
bit numbers, the memory stores 64-bit words, and data and instructions
move between components over a 64-bit bus. The performance of the computer system greatly
depends on the word size. A longer word size would mean better performance.
A 4-bit word size would be able to hold a memory capacity of 16 cells, with address from
0000 (0) to 1111 (15). An 8-bit word size carry 128 memory locations or cells using address
00000000 (0) to address 11111111 (127).
2
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
The operating system must ensure the correct operation of the computer system. To
ascertain that the user-programs do not interfere with the proper operation of the system, the
hardware must provide appropriate mechanisms to assure correct behavior. The appropriate
mechanism that makes a functional operating system which will ensure smooth operation should
include hardware protection, I/O protection, CPU protection and memory protection.
Hardware must support two modes of operation such as user mode and monitor
mode (sometimes called supervisor mode, system mode, and privilege mode). A mode bit
is added to the hardware to identify the current mode. A mode bit of 1 means that the
computer is currently executing on behalf of the user and a mode bit of 0 means that it is
currently executing on behalf of the operating system.
The dual mode of operation provides a means to protect the operating system from
misbehaving users. When an interrupt occurs, the operating system gains control of the
computer (monitor mode). As soon as the interrupt ceases, the operating system sets the
mode bit to 1 (user mode) wherein it passes control to the user program. All hardware
instructions are privileged instructions which can only be executed in the monitor mode.
To protect user program from disturbing normal operation like issuing illegal I/O
instructions, the operating system must define all I/O instructions to be privileged
instructions. This means that the user program must never issue I/O instructions directly,
the instruction must be coursed through the operating system. Also, for I/O protection to
3
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
be complete, the user program should never get control of the computer in monitor mode
because I/O protection will be breached.
To protect user programs from one another and also protect it from the operating
system, one possible way is to separate each program’s memory space by providing a
range of legal addresses it can access. The hardware protection must use two registers
namely, the base and limit registers. The base register holds the smallest legal physical
address and the limit register provides the size of the range. Assuming Program 1 uses a
base register = 100500 and a limit register = 12400. This means that Program 1 can only
legally access memory address 100500 to 112900 inclusive. This method prevents the
user program from intentionally or unintentionally modifying other user programs.
To prevent a user program from getting stuck in an infinite loop, and never
returning control to the operating system, a timer should be set to interrupt the hardware
at specific time interval. Before relinquishing the control to the user program, the operating
system ensures that a timer is set to interrupt. If the timer interrupts, control transfers
automatically to the operating system, which may treat the interrupt as a fatal error or
provide additional time to program to finish processing. The setting of an interrupt is a
privilege instruction.
A timer will protect the user program from running too long. Setting the timer to a
5-minute limit will initialize the counter to 300. Every second, the counter decrements by
one and control is given to the user program as long as the counter is positive. Operating
system takes control when the counter becomes negative.
A timer is useful in implementing time sharing where in each user is given a time
slice to execute. When the timer becomes negative, the operating system gives the floor
to the next user and so on.
4
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
Jochen Liedtke, the kernel denotes the part of the operating system that is mandatory and
common to all other software. Other names for kernel are nucleus or core. The primary purpose
of the kernel is to manage the computer resources and allow programs to request and use
resources. These resources found in Table 2.0 consist of the following:
5
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
Files Data stored on disks or other storage Kernel should be able to access
devices using files. These files are specific file systems by translating
structured in a specific ways to allow commands submitted by user.
faster access. Keeps track of storage resources.
All operating systems contain the following basic components namely: Shell, file manager,
I/O systems manager, process manager, memory manger, security systems manager. Figure 2.1
shows the graphical representation of the components of the operating system. Each component
performs services which are handled by the operating systems as described in Table 2.1.
Succeeding modules introduces each component in details.
6
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
7
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
Note:
1. Use different platforms for the submission of your exercises (Google class page, Email or
Messenger).
2. Submission of your exercises and research will be complied on the specified date only.
Late submission will have deduction on their grade and copying on any course work may
result in a failing grade of 5.0 for all parties involved.
Reading Assignment:
E-Books:
• http://courses.cs.vt.edu/~csonline/OS/Lessons/Resources/index.html
• http://en.wikipedia.org/wiki/Operating_system_kernel
Exercises:
1. If the components of the operating systems are compared to a group of persons (refer to
module 1), what job title will be given to each component? Aside from the given titles
below, can you think of other titles which can be included. Tabulate your answers using
the format presented below.
8
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
Interrupts are signals or events which disrupts the normal processing of the processor.
Here, the processor will just wait for any request from the device. It will only offer its services when
demanded through a signal or a call for help.
Polling is synonymous to a telephone without a ringer or in the silent mode where the
person needs to check every second if there is somebody calling because there is no way of
knowing if someone is on the other line. On the other hand, an interrupt is synonymous to a
telephone with an active ringer which needs to be answered only when it rings.
It is a common event within the computer system when either the hardware or the running
program requests for an audience to settle some internal problems. When this call for help or an
interrupt is received, the hardware automatically suspends whatever it is doing and runs to the
rescue. If multiple interrupts occur, the call for help will be based on priority. As it runs to the
rescue, programs that are currently running are marked to remember where it has left off.
The interrupt can either be a hardware interrupt or a software interrupt. Hardware interrupt means
that a specific device has demanded attention and the operating system decides how to deal with
it. A program requesting for a specific hardware is considered a software interrupt but a printer
issuing an “out of paper” message is a hardware interrupt. Invoking a software interrupt means
automatically running a specific operating system routine in the form of instruction set.
9
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
The actual request of user application program to the operating system is a system call.
A system call triggers a software interrupt that invokes a certain OS routine pertaining to a specific
service by the operating system. Hence, a software interrupt is used to implement a system call.
A system call works as an interface between the process and the operating system. It provides
an entry point to the kernel (basic components of operating system) as the kernel manages all
the resources. As a security measure, the user process must not be given an open access to the
kernel. The only way that an access can be granted is through a system call which invokes the
execution of the kernel code.
There are different types of system calls. These are Process Control, File Management,
Device Management, Information Maintenance and Communications. Below are the different
system calls in each category.
10
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
Note:
1. Use different platforms for the submission of your exercises (Google class page, Email or
Messenger).
2. Submission of your exercises and research will be complied on the specified date only.
Late submission will have deduction on their grade and copying on any course work may
result in a failing grade of 5.0 for all parties involved.
Reading Assignment:
E-Books:
• Kaplan, Yariv. “Interrupts and Exceptions”
http://www.internals.com/articles/protmode/interrupts.htm
• http://www.thocp.net/software/operatingsystems/operating_systems.html
11
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
• http://www.cs.gordon.edu/courses/cs322/lectures/history.html
Exercises
3. What is a system call? Enumerate some types of system call and the function of each
type.
Shell
System Programs
Compilers
User / Application
System Interface to the Kernel
Process Manager
Security Subsystem
File Manager
Memory Manager
Device Drivers
I/O Subsystem
Kernel
Kernel interface to the hardware
Device Controllers
Device (Hardware)
Example: early Unix, MS DOS
12
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
13. Shell
12. User Processes
11. Directories
10. Devices
9. File System
8. Communication
7. Virtual
6. Local Secondary Storage
5. Primitive Processes
4. Interrupts
3. Procedure
2. Instruction Set
1. Electronic Circuit
2.6.3 MicroKernel
1. Approach is to keep the essential functionality in the kernel itself and provide
everything also as a system program
2. Main function is to communicate between user program and the services running in
user / application space
3. Use message passing
4. Examples: MACH, Digital UNIX, MacOS
• Hybrid Structure
• Given that microkernel merely acts as a server for client requests, it is
possible to provide support for more than one API at a time with a separate
server for each, router through the microkernel
• Example: Windows NT which support the interfaces Win32, POSIX, OS/2
13
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
• Modular Kernel
• Similar to monolithic layer structure but allows for partial loading / running of
various kernel components
• For Example, If PCMCIA card services are not required then the module
which handles them is not loaded into the kernel at boot time
• Example: LINUX
There are chips found in your computer such as the ROM (Read only Memory) and the
RAM (Random Access Memory) which are available for storing data. The ROM stores data
permanently and as the name implies, it can only be read and can never be written with anything
onto. The RAM is considered the primary storage. It is commonly known as the main storage.
Small devices such as electronic appliances makes use of the ROM to hold the operating system
but for big devices such as the computer, the ROM may only contain a program called the
“bootstrap program” since the operating system by itself occupies a large amount of space. Given
the volatility of the RAM and the insufficient memory space of the ROM, designers usually store
the operating system in a secondary storage device attached to the computer such as a hard disk.
The procedure of loading the operating system is known as the boot process. The process
involves the following steps:
1. The boot process is activated when the computer switch is turned on.
2. The bootstrap program which resides in the ROM looks for the operating system in the
hard disk.
3. The computer performs a POST (Power-On-Self-Test) that provides a diagnostic test of
the computer’s main circuitry, screen display, memory and keyboard. The POST notifies
if there is a hardware problem by issuing an error message on screen or by sending a
series of beeps.
4. The operating system identifies the peripheral devices that are connected to the
computer and checks their settings.
5. OS is loaded from the hard disk to the RAM.
6. The microprocessor then reads the configuration data and executes any customized
startup routines specified by the user.
7. The computer is ready to accept user commands. It displays an operating systems
prompt or a windows desktop on the screen.
14
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
Note:
1. Use different platforms for the submission of your exercises (Google class page, Email or
Messenger).
2. Submission of your exercises and research will be complied on the specified date only.
Late submission will have deduction on their grade and copying on any course work may
result in a failing grade of 5.0 for all parties involved.
Reading Assignment:
• Stallings, W., “Modern Operating systems” 4th ed. Prentice Hall, 2001
• Silberschatz A., Galvin P. and Gagne G. “Operating Systems Principles”, 7th Ed. John
Wiley and Sons Inc., 2006
E-Books
• http://www.thocp.net/software/operatingsystems/operating_systems.html
• http://www.cs.gordon.edu/courses/cs322/lectures/history.html
• www.cs.huji.ac.il/course/2006/os/ex-slides/ex1.ppt
• www.cs.cornell.edu/Courses/cs414/2008sp/lectures/archsupport-02.ppt
Exercises:
References/Bibliography
1. http://courses.cs.vt.edu/~csonline/OS/Lessons/Resources/index.html
15
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH
2. http://en.wikipedia.org/wiki/Operating_system_kernel
3. http://www.internals.com/articles/protmode/interrupts.htm
4. http://www.thocp.net/software/operatingsystems/operating_systems.html
5. http://www.cs.gordon.edu/courses/cs322/lectures/history.html
6. Kaplan, Yariv. “Interrupts and Exceptions”
7. Nutt, G. (1997), Operating Systems: A Modern Perspective, First Edition, Addison-
Wesley, Reading, MA.
8. Silberschatz A., Galvin P. and Gagne G. “Operating Systems Principles”, 7th Ed. John
Wiley and Sons Inc., 2006
9. Stallings, W., “Modern Operating systems” 4th ed. Prentice Hall, 2001
10. Tanenbaum, A.S. “Modern Operating System”, 2nd Ed. Prentice Hall, 2001
11. www.cs.huji.ac.il/course/2006/os/ex-slides/ex1.ppt
16