Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Republic of the Philippines

POLYTECHNIC UNIVERSITY OF THE PHILIPPINES


LOPEZ QUEZON, BRANCH

COMP 20103 Operating System


Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

MODULE 2: COMPUTER SYSTEM STRUCTURE

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:

At the end of the course, the students should be able to:

• 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.

COMP 20103 Operating System

1
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

LESSON 1: SYSTEM COMPONENTS

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.

2.2 Computer System Structure

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).

COMP 20103 Operating System

2
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

Figure 2.0 A modern computer system


Source: Silberschatz, Galvin, Gagne. “Operating Systems Principles” ©2006

2.3 Computer Operation through the Operating System

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.

2.3.1 HARDWARE 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.

2.3.2 I/O PROTECTION

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

COMP 20103 Operating System

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.

2.3.3 MEMORY PROTECTION

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.

2.3.4 CPU PROTECTION

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.

2.4 Operating System Components


Many processes compete for the attention of the microprocessor. In a given time,
commands may be coming from program the user is currently using, inputs are coming in from
the mouse and the keyboard, data are sent to the display screen or printer and web pages come
from the internet connection. These are all competing for the attention of the operating system so
that each of these processes will receive its share of the microprocessor cycle. With this scenario,
the OS hands are full in controlling each of these processes waiting for their turn. This example
gives us an idea of the services done by OS. Each of these services is performed by a specific
component of the OS. The basic components of the operating system reside in the kernel (see
Figure 2.0), which is the central component of most computer operating systems. According to

COMP 20103 Operating System

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:

Figure 2.1 Resources

2.4.1 Table 2.0 Resources

Resource Description Kernel’s Job


Central Where program are run or executed Takes responsibility for deciding at
Processing Unit any time which of the running
programs may be allocated the
processor.
Memory Where program instructions and Chooses on which part of the
data are stored. Both should be memory each process can be used,
inside the memory in order to be and decides on what to do when
processed by the CPU. Programs there is no enough memory
usually require more memory than available.
what is available.
I/O devices Device used to be able to interact Grants request of users to perform
attached such with the application program. I/O using the appropriate device and
as mouse, other convenient methods for using
keyboard, disk these I/O devices.
drives, printer
and monitor.

COMP 20103 Operating System

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.

Figure 2.2: Components of the Operating System

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.

2.4.2 Table 2.1 Description of the Components of Operating System

Description of the Components of Operating System


Component Description
SHELL • A program (either in the kernel or as a special system application) which
forms the interface between user and OS.
• Separates the user from the OS details and presents the OS simply as a
collection of services
• Includes the API (Application Programming Interface)
▪ a software designed to communicate with the application software
and the user.
▪ a program code that translates requests from an application into
code that the operating system kernel can understand and pass
on to the hardware device drivers, and translates data from the
kernel and device drivers so the application can use it.
▪ Provides an interface to the BIOS.
• A program that interfaces with the OS using CLI and/or GUI

COMP 20103 Operating System

6
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

• Command Line Interface (CLI) features specific commands which


are needed to be types through a keyboard to accomplish a
specific task.
• Graphical User Interface (GUI) features menus and icons which
can be manipulated by clicking the mouse.
SECONDARY • Performs Free space management
STORAGE • Provides Storage allocation
MANAGER • Carries out Disk scheduling
MEMORY • Manages memory
MANAGER • Keeps track of the memory spaces needed by active processes and by
the OS itself
• Brings in and swaps out blocks of data from the secondary storage
PROCESS • Allocates resources to processes
MANAGER • Enables processes to share and exchange information
• Protects the resources of each process from other processes
• Provides facilities for process sharing and synchronization
• Schedules the working dine by the processor
I/O • Provides buffer management (region of memory that holds data while it
MANAGER is waiting to be transferred from one device to another)
• Allocates the I/O channels to communicate with specific device
accepting commands to and/or receive data from devices which in turn
interfaces with the OS and Software application
• Includes device manager which controls communications with the
systems peripheral devices such as keyboard, monitor, disks, tape
drives, printers and modems.
FILE • Service users and applications pertaining to the use of files
MANAGER • Provides services on:
o How to create, delete, read and change files?
o How to move data between files?
o How to back up and recover files?
o How a user may rapidly access files?
• Guarantees that the files will not be corrupted and ensures security of
access.
SECURITY • Protects data and resources from disclosure
MANAGER • Guarantees authenticity of data and messages
• Protect systems from network-based attacks such as preventing users
from accidentally interfering with each other.
• Provide available applications to enforce security
• Provides tracking mechanism of requests for access to resources

COMP 20103 Operating System

7
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

Module 2 – Lesson 1: Exercises/Assessment

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:

Read supplemental books


• Stallings, William. Operating Systems, 4th ed. ©2001
• Nutt, G. (1997), Operating Systems: A Modern Perspective, First Edition, Addison-
Wesley, Reading, MA.
• Silberschatz A., Galvin P. and Gagne G. “Operating Systems Principles”, 7th Ed. John
Wiley and Sons Inc., 2006

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.

Responsible Person Operating Systems Component


Accountant
Receptionist
Security Guard
Traffic Officer
Dispatcher
Manager

COMP 20103 Operating System

8
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

2. What is a resource? Give some examples of resources.


3. Enumerate the hardware mechanisms to help the operating system ensure correct
operation of the computer system.
4. A timer is used for CPU protection. Discuss the mechanism on how the timer is used to
compute the current time.
5. Enumerate the basic components of operating system and discuss briefly the function of
each component.
6. Differentiate a kernel from a shell.

LESSON 2: SYSTEM CALLS AND INTERRUPTS

2.5 System Calls and Interrupts


Processes inside the computer system need to send information to and from the processor
and they expect to get the processor’s attention. This transfer of information may be handled by
the processor in two ways: by either polling or interrupt.
Polling requires the processor to ask each device connected if it needs anything to be
done. This situation warrants that the processor must extend a helping hand by asking everybody
around who ever needs service.

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.

COMP 20103 Operating System

9
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

Figure 2.3 System Calls Interrupts

2.5.1 Table 2.2 Most Common Classes of Interrupts


Most Common Classes of Interrupts
Class Description
Program Conditions that occurs as a result of an instruction execution like:
arithmetic overflow, division by zero, attempt to execute an illegal
machine instruction, reference outside a user’s allowed memory
space
Timer Generated by timer within the processor
Allow OS to perform certain functions on a regular basis
I/O Generated by an I/O controller to signal normal completion an
operation
Hardware Generated by a failure such as power failure or memory parity error
Failure

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.

COMP 20103 Operating System

10
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

2.5.2 Table 2.3 Different types of System Calls

Types of Function Examples of System Call


System Call
Process Control Control Processes End, abort, load, execute, create/terminate process,
wait for time, wait event, signal event, allocate and free
memory, gets/set process attributes
Device Manages Devices Request device, release device, read, write, get/set
Management device attributes, reposition, logically attach or detach
devices
File Manges Files Create file, delete file, open, close, read, write,
Management reposition, get/set file attributes
Information Provides information Get/set time or date, get/set system data, get/set
Maintenance about the system process attributes, get/set device attributes
Communications Exchanges information Create, delete communication connection, send,
with another process receive messages, transfer status information, attach
or detach remote devices

Module 2 – Lesson 2: Exercises/Assessment

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:

Read supplemental books


• Stallings, W., “Modern Operating systems” 4th ed. Prentice Hall, 2001
• Tanenbaum, A.S. “Modern Operating System”, 2nd Ed. Prentice Hall, 2001
• Silberschatz A., Galvin P. and Gagne G. “Operating Systems Principles”, 7th Ed. John
Wiley and Sons Inc., 2006

E-Books:
• Kaplan, Yariv. “Interrupts and Exceptions”
http://www.internals.com/articles/protmode/interrupts.htm
• http://www.thocp.net/software/operatingsystems/operating_systems.html

COMP 20103 Operating System

11
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

• http://www.cs.gordon.edu/courses/cs322/lectures/history.html

Exercises

1. Differentiate a hardware interrupt from a software interrupt.

2. Enumerate and discuss some common interrupts.

3. What is a system call? Enumerate some types of system call and the function of each
type.

LESSON 3: OPERATING SYSTEMS STRUCTURES

2.6 COMMON OS STRUCTURES

2.6.1 Simple Structure, early monolithic Unix structures

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

COMP 20103 Operating System

12
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

Operating System Kernel


• Part of OS that resides in memory at all times, OS nucleus
• Core of the OS that coordinates operating system functions, such as control of
memory and storage.
• Performs the most essential OS tasks, and is protected by hardware from user
tampering.
• Portion of the OS which includes most heavily used portion of software

2.6.2 Layered Approach


• Advantage of modularity which simplifies programming, testing and debugging
• See page 78-80 OS 4th ed by William Stallings
• Example: THE, OS/2, Windows NT (1st release)

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

2.6.4 Other Structures

• 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

COMP 20103 Operating System

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

2.7 Loading the Operating System

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.

COMP 20103 Operating System

14
Republic of the Philippines
POLYTECHNIC UNIVERSITY OF THE PHILIPPINES
LOPEZ QUEZON, BRANCH

Module 2 – Lesson 3: Exercises/Assessment

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:

Read supplemental books

• 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:

1. Define the following terms:


a. Monolithic kernels
b. Microkernels
c. Exokernel
d. Hybrid kernel
e. Nanokernel

2. Differentiate Cold Boot and Warm Boot.


3. Discuss in your own words how the operating system is loaded in the computer.
4. What is a Safe Mode? When does it occur? What happens when your computer is on
a Safe Mode?

References/Bibliography

1. http://courses.cs.vt.edu/~csonline/OS/Lessons/Resources/index.html

COMP 20103 Operating System

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

COMP 20103 Operating System

16

You might also like