0% found this document useful (0 votes)
41 views26 pages

ISO Unit 01 Fundamentals OS

This document discusses the history and functions of operating systems. It provides definitions of operating systems and describes their role in managing hardware resources and allowing users to run applications. The document then outlines the evolution of several major operating systems, including Windows, Apple's OS, and Linux. It explores operating systems used in mobile phones and personal computers. Finally, it details several key functions of operating systems, such as process management, memory management, input/output management, and file management.

Uploaded by

Betzy Iñiguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views26 pages

ISO Unit 01 Fundamentals OS

This document discusses the history and functions of operating systems. It provides definitions of operating systems and describes their role in managing hardware resources and allowing users to run applications. The document then outlines the evolution of several major operating systems, including Windows, Apple's OS, and Linux. It explores operating systems used in mobile phones and personal computers. Finally, it details several key functions of operating systems, such as process management, memory management, input/output management, and file management.

Uploaded by

Betzy Iñiguez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

Subscribe to DeepL Pro to edit this

Visit www.DeepL.com/profor more information.

IMPLEMENTATION OF
OPERATING SYSTEMS
DIDACTIC UNIT 1: FUNDAMENTALS OF OPERATING
SYSTEMS
INDEX
1. Definition of SO ......................................................................................................................................................................... 2
2. Historical development of SO .................................................................................................................................................... 2
2.1. Evolution of Windows OS ................................................................................................................................................ 4
2.2. Evolution of Apple's OS ................................................................................................................................................... 4
2.3. Evolution of Linux operating systems .............................................................................................................................. 5
3. Types of Operating Systems....................................................................................................................................................... 6
4. Current Operating Systems........................................................................................................................................................ 7
4.1. Mobile phones................................................................................................................................................................ 7
4.2. Personal Computers (PCs) ............................................................................................................................................... 7
5. Functions of an OS..................................................................................................................................................................... 9
A. PROCESS MANAGEMENT ........................................................................................................................................................ 10
1. Introduction ........................................................................................................................................................................ 10
2. Processes ............................................................................................................................................................................ 10
3. Process planning.................................................................................................................................................................. 12
4. Processes on Windows and Linux ......................................................................................................................................... 15
B. MEMORY MANAGEMENT ....................................................................................................................................................... 16
1. Introduction ........................................................................................................................................................................ 16
2. Relocation issue................................................................................................................................................................... 16
3. Memory protection problem ............................................................................................................................................... 17
4. Memory allocation problem ................................................................................................................................................ 17
5. Memory shortage problem. Virtual memory ........................................................................................................................ 17
6. Memory management on Linux and Windows ..................................................................................................................... 18
C. INPUT/OUTPUT MANAGEMENT .............................................................................................................................................. 18
1. Introduction ........................................................................................................................................................................ 18
2. Input/output unit ................................................................................................................................................................ 19
Input/output software............................................................................................................................................................. 19
4. Input/output hardware ........................................................................................................................................................ 19
5. Disk management ................................................................................................................................................................ 20
D. FILE MANAGEMENT ................................................................................................................................................................ 22
1. Introduction ........................................................................................................................................................................ 22
2. Files..................................................................................................................................................................................... 22
3. Directories........................................................................................................................................................................... 23
4. Allocation methods.............................................................................................................................................................. 24
5. Examples of file systems ...................................................................................................................................................... 25

1
1. DEFINITION OF SO

The Operating System is the basic software of the computer. It is in


charge of managing all the hardware resources of the IS (it acts as an
intermediary between the user and the hardware, hiding its complexity User 1 User 2 User N
with a user-friendly interface and using them efficiently). Once the
Operating System is loaded, it is possible to run applications.

System programmes and applications

Operating System

Hardware

Components of a Computer System


2. HISTORICAL DEVELOPMENT OF SO
Computer science as we know it today emerged in the
aftermath of World War II, in the 1940s. In those years,
the concept of "Operating System" did not even exist
and programmers interacted directly with the computer
hardware, working in machine language (i.e. in binary,
programming only with 0s and 1s).

The concept of an Operating System emerged in the


1950s. The first Operating System in history was created
in 1956 for an IBM 704 computer, and basically all it did
was to start the execution of a program when the
previous one finished.

The 1960s saw a revolution in the field of operating


systems. Concepts such as multitasking system,
multiuser system, multiprocessor system and real-time
system appeared.

It was at the end of this decade that UNIX appeared, the basis of the
great majority of the Operating Systems that exist today.

The 1970s saw a boom in personal computers, bringing them to the


general public in a way that was unthinkable until then. This led to an
explosion in development, with the creation of the C programming
language, specifically designed to completely rewrite the UNIX code.

As a consequence of this exponential growth of users, most of them


without any knowledge of low or high level languages, in the 80s, the
priority when designing an operating system was ease of use, thus giving
rise to the first user interfaces.

The 1980s saw the birth of systems such as MacOS, MS-DOS,


Windows.

2
In the 1990s Linux made its appearance,
releasing the first version of the kernel in
September 1991, which later joined the GNU project, a completely free
operating system, similar to UNIX, which lacked a functional kernel to
function. Today, most people know Linux as the operating system that is
actually called GNU/Linux.

For more information on OS developments, see the Annex or go to:


http://timerime.com/en/timeline/1007132/Evolucin+of+the+Operational+Systems/

3
2.1. EVOLUTION OF WINDOWS OS

2.2. EVOLUTION OF APPLE'S OS

4
2.3. EVOLUTION OF LINUX OPERATING SYSTEMS

5
ISO - Theme 1: Fundamentals of Operating Systems
3. TYPES OF OPERATING SYSTEMS
OS can be classified according to:

No. of users:

o Single user: only 1 user can use the system resources at a time

o Multi-user: multiple users can use system resources simultaneously

Therefore, even if more than one user is logged on to the system, if they cannot work simultaneously, the OS is not
multi-user.

No. of processes or tasks:

o Single-tasking: can only run 1 task at a time.

o Multitasking or multiprogramming: can run several programs at the same time

No. of processors:

o Monoprocessor/monoprocessor: the OS is capable of managing only 1 processor, so if it had more it would be


useless. In this OS, the processes will alternate their occupation in the CPU.

o Multiprocessing/multiprocessor: the OS is able to manage multiple processors, so that it can use them
simultaneously to distribute its workload. These systems work in two ways:

 Asymmetric: the OS divides the tasks it is performing between the processors. Certain processes will
always be executed by one processor, and the other processor will only be used to carry out user
processes. In this case, it is possible that one process is always working and the other is sometimes
inactive.

 Symmetric: processes are sent indistinctly to any of the available processors.

Response time (time it takes for the user to obtain the results after starting the execution of a program):

o Batch processing: the response time is not important and is usually high. Processes are executed sequentially one
after the other. There is no user interaction. Example: backups

o Time sharing: the processor divides its time between all processes (using scheduling algorithms such as Roud Robin).
Example: interactive multi-user systems (users interact with the system).

o Real-time: in these OS, processes require a very low or immediate response time. Examples where this is especially
important: systems where response time is crucial such as medical systems for patient monitoring, banking systems,
air traffic...

Operating System No. of users No. of processes No. of processors Response time
MS-DOS Monkey Monkey Monkey Real
Windows 9x, Me Monkey Pseudo multitasking Monkey Shared
Windows NT Workstation, Mono/Multi Multi Multi Shared
2000 Professional,
XP/Vista/7/8
UNIX, Linux, Multi Multi Multi Shared
Windows NT Server, Windows
2000 Server, 2003 Server and
2008 Server
Note: Pseudo-multitasking OSs are OSs capable of loading more than one process into memory and seemingly running more
than one process at the same time. However, these OS are not capable of using more than 1 processor so that, in reality, only
one process is executed at a time (the processor executes sequentially each of the started processes).

6
ISO - Theme 1: Fundamentals of Operating Systems

4. CURRENT OPERATING SYSTEMS

4.1. MOBILE PHONES

Android

- Free OS created by Google and the OHA (Open Handset Alliance) which is a
consortium of hw and sw manufacturers and mobile operators.

- It is based on the Linux kernel.

- It can be installed on all types of mobile phone models and brands, as well as tablets,
netbooks...

iOS

- OS created by Apple

- Does not allow it to be installed on any non-Apple device.

4.2. PERSONAL COMPUTERS (PCS)

Windows

- Kernel type: Monolithic (MS-DOS based versions). Hybrid (Windows NT-

based versions).

- Licence: Microsoft CLUF/EULA (End User Licence Agreement): does


not allow the software to be modified, disassembled, copied or
distributed.

- Closed code.

- Latest version: Windows 8, Windows Server 2012

- Windows XP, Vista, 7, 8: multi-tasking and single user

- Windows 2003, 2008 and 2012 Server: multitasking and multiuser

- Usage in Spain in October 2012: 87%.

Microsoft's Windows OS is proprietary software, unlike Linux, which is free software, meaning that in order to install and use it on a
computer, a licence must be purchased.

Following Apple's Mac OS, Windows was one of the first to incorporate a window-based graphical user interface, hence its name.

In its early days, it was an application running on top of the text-mode interface OS MS-DOS, also developed by Microsoft, but later
became a real OS (with Windows 95).

Throughout its history, there have been several versions of Windows that have
added improvements in its graphical environment, in its performance, in the use
of the hardware characteristics of the computer and in the utilities
applications to facilitate the user's work.

Currently, the most widely used versions are Windows XP and Windows 7.

Linux

7
ISO - Theme 1: Fundamentals of Operating Systems
- Kernel type: Monolithic. Based on Unix OS. Latest stable kernel version : 3.6.1

- Free and open source software

- Current Linux distributions: Mint, Ubuntu, Fedora, Debian, Mageia, OpenSUSE

- Multi-user and multi-tasking.

- Usage in Spain in October 2012: 2.03%.

It is a freely distributed OS, so it can be installed and updated free of charge. It is also open source, so we can use its source code to
introduce modifications or improvements.

Over the years, it has introduced significant improvements in graphical user interfaces. In addition, there are many distributions and
window managers for the graphical environment, so the user can choose the distribution that best suits his needs or the one he
likes the most, where he can choose which window manager he wants to use.

Linux has also improved considerably in terms of the hardware on which it is installed and in terms of improvements and new
features in the software that can be installed.

Mac OS X

- Core type: hybrid. XNU based on Mach and BSD


of Unix.

- License: Proprietary / Apple CLUF

- Closed source with open source components (such as


Darwin and WebKit)

- Latest version: Mac OS X Mountain Lion

- Multitasking and multi-user

- Usage in Spain in October 2012: 6.61%.

OS X is an operating system developed and marketed by Apple that has been included in its range of Macintosh computers since
2002. It is based on BSD. Since Mac OS X 10.5 Leopard for Intel processors, the system is UNIX certified (this allows certification that
it can run certain software, such as Oracle).

Mac OS X version names are named after big cats, for example: Mac OS X v10.7 is called "Lion".

8
ISO - Theme 1: Fundamentals of Operating Systems

5. FUNCTIONS OF AN OS

With regard to the functions of any Operating System, we can highlight the following:

- Process management
- Memory management
- I/O device management
- File system management
- Network management
- Protection

A. Process management: the OS must be able to support:


 Creating, suspending, suspending, resuming, deleting and scheduling processes
 Communication and synchronisation between processes.

B. Memory management: the OS must be able to solve the following problems:


 Relocation: A process can run in different sections of physical memory.
 Scarcity: processes may need more memory than they have available.
 Protection: the memory area allocated to a process must be private and must not be 'invaded' by other processes.
 Allocation: physical memory must be allocated among the running processes.

C. I/O device management: the OS must be able to manage the different existing peripherals. To do so, the OS must:
 Send commands to devices
 Determining the device that needs the processor's attention
 Detecting interruptions
 Controlling errors
 Provide an interface between the devices and the rest of the system, which should be simple and easy to use and the same
for all devices.

D. File system management: the OS must be able to provide a simple working model with disks. It must also be able to provide a
solution to the following problems:
 Organisation of the file system (directories)
 Allocation of disk space to information (in a non-contiguous way)
 Management of free and occupied disk space

E. Network management: which comprises several levels:


 Network card drivers
 Communication protocols (which solve network access and provide an interface for communication between remote
processes)
 Applications for network use (e.g. www, ftp..., which are applications built on top of the communication interface that
facilitate access to remote resources).

F. Protection: requires a mechanism to allow/deny a user process access to a resource (files, I/O devices). This requires:
 Design of a protection model and policy to define which accesses are legal/illegal.
 Implementation of a mechanism to monitor compliance with the defined protection rules.
 Mechanism to guarantee the privacy of information against attacks by intruders.

9
ISO - Theme 1: Fundamentals of Operating Systems

A. PROCESS MANAGEMENT

1. Introduction

In terms of process management, the OS must be able to support:


 Creating, suspending, suspending, resuming, deleting and scheduling processes
 Communication and synchronisation between processes.

2. Processes

A process is an executing program that needs to be loaded into memory and have resources (CPU, memory, files, I/O devices) to
accomplish its purpose. It is an active entity. While programs are a set of files that are stored in some storage device (hard disk,
pendrive...) and whose source code is written in some programming language. When this set of files is executed, then it becomes a
process.

2.1 States

The state of a process is defined by its current activity, changing as it executes. The execution of a process alternates a series of CPU
and I/O bursts.
Process terminated
by another process

Admitted Chosen by planner Termination


NEW FINISHED

PREPARED IN
IMPLEMENTAT
Expulsion ION Wait for I/O
End I/O or or event
event arrival LOCKED
Process terminated
by another process

States of the processes


Most important transitions:
 New-Ready: the OS is ready to support one more process (Long-Term Scheduler).
 Prepare-Execute: The (short-term) planner chooses a process for execution.
 Execution-Ready: The running process is interrupted and ejected from the processor because it has already used up its
allotted time or because another process of higher priority is waiting.
 Execution-Blocked: The process voluntarily leaves the CPU and waits for an external event.
 Blocked-Ready: Ends the event that was waiting for the process and goes to the ready state.
 Execute-Terminated: The process terminates its execution (normal termination).
 Ready/Blocked-Terminated: The process is terminated (abnormal termination).

10
ISO - Theme 1: Fundamentals of Operating Systems

2.2 Implementation

When a process executes, the OS allocates it a memory address space (containing the instructions, data and stack (structure for
storing and retrieving data) of the process) and adds it to a process table.
The O.S. stores in the process table for each process a data structure called Process Control Block (PCB) that stores the following
information:
 Process identification (of the process itself (PID), of the parent process (PPID) and of the user)
 Process status information: ready, running, blocked...
 Priority of the process
 Memory address where the process was loaded
 Other (resources used, values of processor registers, owner, permissions...)

To give a sense of concurrent execution or multi-scheduling, CPU time must be shared between processes. This involves context
switches that consist of taking CPU away from the "running" process and allocating it to another process in the "ready" state. This
operation is performed by an O.S. component called a dispatcher or short-term scheduler, which saves the context of the running
process on its PCB and restores the context of the new process to be executed via its PCB.

PROCESS 1 OPERATING SYSTEM PROCESS 2

Inactive
In progress

Save context of the P1 on your PCB


Select process P2
Load P2 context from your PCB

In progress
Inactive

Save P2 context on your PCB


Select process P2
Load P1 context from your PCB
In progress Inactive

Contextual changes

Context switches can be overloading if they are used very frequently. In general, they usually occur when a process is terminated,
expelled or suspended.

2.3 Threads

In current O.S.'s a process can internally have several concurrent activities called threads.
They are like "mini-processes", small units into which a process is divided, each of which performs an action.

2.4 Processes and services

Processes running on a computer can be in the foreground or background. Foreground processes interact with users, while
background processes perform a specific function without user interaction. In addition, processes can be user-owned or OS-owned.

In this way, the operating system can create processes, some of which reside in the background and are called services in Windows
and daemons in Linux. The system administrator can start, stop, pause, resume... these services. The processes that belong to the
system run in kernel mode or privileged mode (they will be able to access any resource).

Other processes are user-created processes, where the user interacts with them, i.e. they run in the foreground, e.g. Firefox. These
processes run in so-called "user mode" (with restricted access to hardware resources).

11
ISO - Theme 1: Fundamentals of Operating Systems

3. Process planning

As mentioned above, in a multitasking O.S., multitasking is achieved through the alternative execution of processes.

The part of the O.S. responsible for selecting the next process to execute is the short-term scheduler and the algorithm it uses is the
scheduling algorithm.

3.1 planners and queues


The main CPU schedulers are:
 Long-term planner:

o Selects processes not loaded in memory (new or ready processes that have been unloaded from memory) and
loads them into memory.

o Control the degree of multi-programming. It is important that you choose a balanced set of processes.

o It is executed infrequently.

 Short-term planner:

o It selects from among the memory-ready processes and allocates the CPU to them.

o It is executed very frequently.

 Medium-term planner:
o It decides which process moves from main memory to secondary memory (virtual memory) or vice versa.

The O.S. links the PCBs of the processes that are in the same state to the various queues that may exist.

Key policies for planning:


 Non-appropriative planning: (non-expulsive algorithms)

o Processes run until they terminate or crash.

o Simple to implement.

o Negative performance overall.

 Appropriative planning: (expulsive algorithms)

o Processes can be kicked out of the CPU.

o Higher implementation cost. Need additional hardware support (clocks)

o Improves service and avoids CPU monopolisation.

12
ISO - Theme 1: Fundamentals of Operating Systems

3.2 Planning algorithms

They choose the next process to enter the CPU. The main scheduling algorithms are:

 FCFS (First Come First Served) supermarket queue


The CPU is allocated to processes in the same order as they request it. It is a non-expulsive algorithm.

Advantages:
- Simple to implement (FIFO queue).

Disadvantages:
- Poor average waiting time.
- Convoy effect (processes with long CPU bursts slow down processes with short bursts).
- Not valid for interactive processes.

Process Moment of arrival CPU time


P1 0
P2
P3 5
Average waiting time =
P1 P2 P3 (0+10+9)/3=6.3
||||||||||||||||||
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

 SJF (Shortest Job First) first which requires the least total CPU time
The process in the ready queue with the next shortest CPU streak is chosen and executed until it is terminated or suspended. If
there are multiple processes with equal CPU spans, FIFO can be applied. Non-expulsive algorithm.

Advantages:
- Optimise waiting time

- Favours I/O oriented processes

Disadvantages:
- It is costly to find out how long the next CPU burst lasts

- Starvation of processes with long CPU spells.

Process Moment of arrival CPU time


P1 0
P2
Average waiting time =
P3 1
(0+6+3)/3 = 3
P1 P3 P2
|||||||||||||
0 1 2 3 4 5 6 7 8 9 10 11 12

 SRTF (Shortest Remainig Time First) first with the least CPU time left to finish.

Proprietary version of SJF (like SJF, only you can throw it into processes)

Process Moment of arrival CPU time


P1 0
P2
P3 1

P1 P2 P3 P2 P1 Average waiting time =


|||||||||||||
0 1 2 3 4 5 6 7 8 9 10 11 12 (5+1+0)/3 = 2

13
ISO - Theme 1: Fundamentals of Operating Systems
 Prioritised planning first that which has the highest priority
Each process is assigned a priority. The scheduler selects the process with the highest priority (equal priority is selected with
FCFS).

Priorities can be dynamic (they change over time) or static (they remain the same).

Disadvantages:

- Risk of starvation of processes with low priority. One solution would be to increase the priority by increasing the
timeout.

Process Moment of CPU time Priority


arrival
P1 0 5
P2
P3 1

Priorities without expulsion:

P1 P3 P2 Average waiting time:


|||||||||||||
0 1 2 3 4 5 6 7 8 9 10 11 12 (0+6+3)/3=3

Priorities with expulsion:

P1 P2 P3 P2 P1 Average waiting time =


|||||||||||||
0 1 2 3 4 5 6 7 8 9 10 11 12 (5+1+0)/3 = 2

 Round robin planning all the same time in turns


- Each process is allocated an amount of CPU time called a "quantum". If the process has a CPU interval greater than the
quantum it is ejected from the CPU.

- The preparation queue is managed with a FIFO policy.

- If the value of quantum is large the algorithm degenerates into FCFS. If it is small, an overhead will be generated due to
context switches.

- It is equitable

E.g. (Quantum = 2):


Process Moment of arrival CPU time
P1 0
P2 0
P3 0 1

P1 P2 P3 P1 P2 P1 Average waiting time=


|||||||||||
0 1 2 3 4 5 6 7 8 9 10 (4+5+4) / 3 = 4.3

14
ISO - Theme 1: Fundamentals of Operating Systems

4. Processes on Windows and Linux

We can see the processes, as well as their CPU and RAM consumption:

- On Windows:

o "Task Manager" (by pressing alt+ctrl+delete)

o "Resource Monitor" (run resmon; default in Win7)

o "Process Explorer" (http://download.sysinternals.com/files/ProcessExplorer.zip )

- On Linux:

o "System Monitor" (system administration system monitor)

15
ISO - Theme 1: Fundamentals of Operating Systems

B. MEMORY MANAGEMENT

1. Introduction

This will be followed by an analysis of the memory management problems that every OS must solve (memory reallocation,
protection, allocation and scarcity), as well as the
techniques used to solve them, with a special emphasis on
sparse allocation and virtual memory techniques.

In this memory management task, there is a key


component: the MMU (Memory Management Unit),
which is a hardware component, usually integrated in the
CPU, responsible for handling memory access requests
from the CPU.
Specifically, the MMU is responsible for transforming the
logical or virtual addresses issued by the CPU into
physical addresses received by the memory and for
protecting the memory, among other functions.

Therefore, just as a computer has a physical memory, we can consider that each process has its logical or virtual memory.

2. Relocation issue

A process must be able to execute in different physical memory locations, which implies that references to memory that exist in the
program code have to be concretised in physical memory locations.

In addition, if a process is sent from main memory to secondary memory, when it is loaded back into main memory, it must be able
to do so in a different memory location than where it was initially.

This can be resolved at any of the following stages: In the following graph, we can see a comparison of
the methods:
- Compilation

- Charge

- Execution

16
ISO - Theme 1: Fundamentals of Operating Systems

3. Memory protection problem


Exception
Processes can ONLY access their
own physical address space (unless MEMORY
MMU
the system allows sharing of
memory areas). Therefore, the OS NO
must prevent a process from logical direction
invading the memory area of
< YES
+
another process or the OS. For 9800
example: by using base and 9200
boundary registers containing the Register Register
start and end address, respectively, limit base
of each process' memory area.
Example: suppose that the CPU issues the logical address 9800, as this must not exceed 9200 and the address that has been issued
is higher, the MMU does not allow it and warns the CPU of the error. If the logical address issued was less than the limit register, the
value of this address would be added to the base register, giving rise to the physical memory address to be accessed.

4. Memory allocation problem

Physical memory can be allocated to the various running processes using a variety of techniques:

- Contiguous allocation

- Dispersed allocation

4.1 Contiguous allocation

The logical address space of a process is mapped onto a single area of physical memory: memory
addresses are contiguous.

Methods:
- Fixed partitions

- Variable partitions

4.2 Disparate allocation

Logical memory is divided into chunks (pages or segments), which are mapped onto non-
contiguous areas of physical memory.

Dispersed allocation techniques:


- Pagination
- Multilevel pagination
- Segmentation
- Paged segmentation

To implement these techniques, the support of the MMU is needed. These techniques will not be studied in this course.

5. Memory shortage problem. Virtual memory


17
ISO - Theme 1: Fundamentals of Operating Systems

The causes of this problem are:


- Processes need more physical memory than is available.
- Increasing the degree of multi-programming.

Techniques that provide a solution to this problem are: the swapping method (using the disk to store the memory image of
processes that do not fit) and the Virtual Memory technique.

The Virtual Memory technique allows processes to be executed without all their logical space being loaded in main memory by
using secondary memory (hard disk). It consists of loading into main memory the part of the process that is currently running, while
the part of the process that is not running is left in secondary memory.

The advantages of virtual memory are


- Processes whose size is larger than
physical memory can be loaded

- Increased degree of multi-


programming

- Memory saving

Disadvantages:
- Can reduce system performance if not
properly designed and synchronised

- Increased complexity

The basic virtual memory techniques: paging and demand segmentation. These techniques will not be studied in this course.
6. Memory management on Linux and Windows

Linux: Windows with NT kernel (Windows XP, 7...):


- It uses multilevel paging. - It uses multilevel paging.

- In page replacement it uses the clock algorithm - It uses a disk paging file called pagefile.sys, the size
(similar to LRU). of which is set in the control panel system
performance.
- It uses a swap partition called swap.

C. INPUT/OUTPUT MANAGEMENT

1. Introduction

Input/output management is one of the most important functions of the OS, as the OS must be able to handle the different
peripherals available.

To do so, it must:

- Send commands to I/O devices


- Determining the device that needs the processor's attention
- Detecting interruptions
- Controlling errors
- Provide an interface between the devices and the rest of the system. This interface must be:
o Simple and easy to use.
o It must be the same for all devices.

The OS has several ways to carry out I/O:

18
ISO - Theme 1: Fundamentals of Operating Systems

- Scheduled I/O: The processor executes a program that controls I/O operations. The problem is that the processor has to
wait (continuously querying the I/O device) for a response.
- Interrupt-driven I/O: Devices send an interrupt signal to get the attention of the system. The processor can continue to
perform operations and attends to the I/O request when the interrupt occurs.
- I/O using DMA (direct memory access): a chip performs the transfer and accesses the memory to read or write data
received and sent by the device without passing through the processor.
Currently hard disks, CD, DVD, Blueray drives support DMA and have it enabled by default.

Since the speed of the processor is much higher than that of the I/O devices, buffering techniques are used to improve system
performance:

- Caching: consists of storing a temporary, fast-access cache of the most frequently used data. In this way, the most
frequently used data is not requested from the device (e.g. hard disk cache).

- Buffering: consists of using an area of memory as a buffer, simulating a device or a logical peripheral, which will act as an
intermediate device between the real peripheral and the processor. The buffer is independent of the input and/or output
device, so it allows the processor to start working by reading or buffering while the information from the peripheral is being
stored or extracted from the buffer. This prevents a slow peripheral from affecting the performance of the computer
equipment.
- Spooling: A technique in which the computer puts jobs into a buffer (a special area in memory or on a disk), so that a device
can access them when it is ready. Spooling is useful for devices that access data at different speeds. The buffer provides a
waiting place where data can sit until the (usually slower) device processes it. This allows the CPU to work on other tasks
while waiting for the slower device to finish processing the job.
The most common application of spooling is printing. In this case, documents are loaded onto an area of a disk, and the
printer spools them off the disk at its own speed and in a coordinated manner so that jobs are not mixed up. Spooling also
allows users to place several print jobs in a queue at once.

2. Input/output unit

The Input/Output Unit (chipset) allows the


Memory UCP
communication of the CPU and the Main Main
Memory with the outside: printers, monitor, Control Registers Arithmetic
Unit Logic Unit
keyboard, etc.

In order for the exchange of information to take


place, the following tasks must be carried out:
Buses
- Addressing: selection of the I/O device (data+direc+control)
involved in a given transfer
- Synchronisation of PCU and peripherals: Input/Output Unit
it is necessary to coordinate the activity
of the PCU with the peripherals, as their
Peripherals
working speeds are different.
- Transferring data to or from the
selected device
3. Input/output software

The I/O software is organised in levels. Those


on the lower level hide hardware peculiarities
from those on the upper level which present a
simple and uniform interface to the user.
Driver

4. Input/output hardware

19
ISO - Theme 1: Fundamentals of Operating Systems

In general, I/O units consist of:

- An electronic component called a controller


- A mechanical component, which is the device itself.

Controllers:

The main functions of the controllers are:

- Communication with the peripheral, exchange of commands, status information.


- Error detection.
- Communication with the processor, decoders for commands, data, status information, address recognition.

The specific code that the OS uses to program a controller is known as the controller driver. Thus, in order to carry out I/O
tasks, the OS, using the driver, communicates with the controller through a series of specific registers that each controller has.
When the order has been fulfilled, the controller produces an interrupt in order to allow the CPU to attend the OS to check the
results of the I/O operation. The values of the controller registers that report the final state are used for this check.

I/O devices:

Peripherals can be classified according to whether they manage information by blocks or by characters.

5. Disk management

Disks are non-volatile mass storage. They support the file system and the virtual memory system.

Main advantages of discs:

- Increased storage capacity.


- Lower price per bit.
- Information is not lost when the PC is switched off.
Partitions on a hard disk:

You can have different types of file systems by partitioning a hard disk, i.e. dividing the physical disk into two logical disks.

- In order to have more than four partitions on a disk, there is a special type of partition, the extended partition. An extended
partition allows you to define an unlimited number of logical partitions within it.

- The MBR (Master Boot Record) occupies the first sector of the disk,
containing the boot program, the partition table with four entries and the
magic number (0xAA55). entries and the magic number (0xAA55).
- The remaining sectors of the disk may belong to a partition.
(formatted or not) or be available for assigning
- Each entry in the table contains the type of partition, if it is the partition
active or not and the start and end position on the disc

20
ISO - Theme 1: Fundamentals of Operating Systems

Structure of a disc:

Cylinder

Track

Sector or physical block (Note: A cluster is a


contiguous set of sectors that make up the smallest
unit of storage on a disk. Files are stored in one or
more clusters depending on their size.)

Head

Hard disk interior view: http://www.youtube.com/watch?v=Y7U8M6UsEwE

The time to read or write a disk sector is mainly determined by


these factors:

- Moving the heads on the requested cylinder => search


time

- Waiting for the sector to pass in front of the head =>


latency time

- Read or write sector => transmission time

The most costly is the seek time (time taken by the disk to move the
heads over the requested cylinder), so the requests to disk must be
planned in an order that minimises the head travel (following
algorithms such as FCFS, SSTF, SCAN...). This has to be achieved by
the device handler (driver).

Planning algorithms:

FCFS (first come - first served) Example: Spindle position: cylinder 53


Tail (no. of cylinders): 98, 183, 37, 122, 14, 124, 65, 67
 Planning on a first-come, first-served basis.

 Advantages: simple implementation

 Disadvantages: high overall travel and jerky spindle


movements

SSTF (shortest search time first)

 Closest cylinder first (shortest positioning time) Example: Spindle position: cylinder 53
Tail (no. of cylinders): 98, 183, 37, 122, 14, 124, 65, 67
 Advantages: lower overall travel distances

 Disadvantages: The head oscillates over the central area


(possible starvation).

21
ISO - Theme 1: Fundamentals of Operating Systems

SCAN (sweep)
Example: Spindle position: cylinder 53
 The spindle travels from one end of the disc to the other, Tail (no. of cylinders): 98, 183, 37, 122, 14, 124, 65, 67

taking requests along the way; when it reaches the end of


the disc, it changes direction.

 Advantages: low overall travel, no starvation

 Disadvantages: Endpoint requests have high service times.

D. FILE MANAGEMENT

1. Introduction

- File or archive: Set of information of a certain type that is stored in a storage device. Example: text document, song, image...

- Folder or directory: A special type of file used to organise files (or other folders).

- File system: The part of the OS that allows the "management" of stored information from I/O devices in the form of files.

Its objectives are:

o Create, modify or delete files (or folders)


o Control access to files (through permissions)
o Allow data exchange between files.
o Allow backup copies of files to be made
o Allow access to files by symbolic names.

2. Files

- File names and file extensions

The files generally consist of:

o Name: Most OS allow names up to 255 characters long and some OS, such as Linux, are case-sensitive.
o Extension: it is used to know the program that allows to execute or open a file. Some OS like Linux do not require the
use of extensions.

- File types:

o Normal or regular files: Those files that contain data (information).


o Directories: file used to organise files (or other folders).
o Special device files: represent I/O devices

- Information contained in a file:

o Name
o Size
o Dates: of creation, modification...
o Owner
o Permissions (read, write, execute...)
o Location
o Links: points from which the file can be accessed.

- Operations that can be performed on a file:


22
ISO - Theme 1: Fundamentals of Operating Systems

o Create it
o Open it
o Write it down
o Close it
o Delete it

3. Directories

- Operations that can be performed on a file:

o Create it
o Entering it
o Getting out of it
o Read its contents
o Adding or deleting files or directories to or from it
o Delete it

- Directory structures:
Types:

o One level: all files in a single o Hierarchical: a directory can include other directories and files
directory

Directory tree Directory network

Most operating systems have a hierarchical file system structure, where directories start from one directory called the root
directory, from which all other directories hang in a tree-like structure, hence the use of terms such as subdirectory tree.

- Special directories:
o There are two types:

 . → current directory
 .. → parent directory

- Paths: concatenation of directories and subdirectories to call a file in a directory


structure.

Types:

o Absolute: the file is called from the root directory to the file. Example:
C:\web\imagenes\logo.gif
o Relative: the file is called from the current directory we are in. Example:
if we are in the folder "web" the path to the file "logo.gif" would be:
imagenes/logo.gif

23
ISO - Theme 1: Fundamentals of Operating Systems

4. Allocation methods

- Definición: métodos de asignar espacio a cada fichero dentro del disco.


1- Types: 5 8
o Contiguous allocation: blocks of a file are contiguously located on disk.
File A

1 5 8
d d d d d=data
end 5 from the
file
o Linked mapping: in each block there is part of the file data and a small part to
1st block of the file
indicate the next block containing the file data.
1 5 8

8
o Indexed allocation: for each file, the OS has a small index table indicating the
blocks of each file.

24
ISO - Theme 1: Fundamentals of Operating Systems

5. Examples of file systems

FAT16 FAT32 NTFS ext4


Operating Systems MS-DOS 6.22 W98SE W2000 Linux
W95 W2000 WXP
W98 WXP W2003
W2003 W2008
W2008 W7
W7
Max. file size 2 GB 4 GB limited by the size of the volume 16TB
Max. partition size In practice, 16TB using 4KB clusters (allows to define the
size of the cluster, starting from 512 bytes which is the
2 GB 2 TB 1EB
minimum size of a sector). Although the recommended
maximum is 2TB

FAT16:
- The size of partitions and files could not exceed 2GB.

- The name of the files had to be 8 characters for the name and 3 characters for the extension.

FAT32:
- This file system was introduced for Windows 95 OS and was used by Win98 and Me.

- Supports 2TB partitions

- File names can have more characters (255) and files can be larger (4GB).

NTFS:
- It improves on the previous file system by introducing better security, greater stability and larger file sizes.

- It is used for Windows NT, 2000, XP, Vista, 7, 8 and Server 2000, 2003, 2008 and 2012.

EXT2, EXT3, EXT4:


- File systems supported by most Linux distributions.

- The ext3 version is an enhancement of ext2, with some new features such as journaling (a technique that records daily changes
to the file system so that data can be recovered in case of failure) and ext4 is an enhancement of ext3, with further
improvements such as support for larger partitions and files, improved reliability and speed.

- All three systems are compatible with each other.

OTHERS:
- Other file systems on Linux are XTS or reiserFS.

- In Mac OS we highlight the Mac OS Extended (HFS Plus) file system, which replaces HFS, and the UFS file system.

- In UNIX we highlight UFS.

25

You might also like