• No results found

3. Operating Systems

N/A
N/A
Protected

Academic year: 2021

Share "3. Operating Systems"

Copied!
14
0
0

Loading.... (view fulltext now)

Full text

(1)

Rev: 1.16 Definition Processes File System User Interface

3. Operating Systems

Inform´atica

Ingenier´ıa en Electr´onica y Autom´atica Industrial

Ra´ul Dur´an D´ıaz Juan Ignacio P´erez Sanz ´

Alvaro Perales Eceiza

Departamento de Autom´atica Escuela Polit´ecnica Superior

Course 2014–2015

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 1 / 28

Definition Processes File System User Interface

Contents

1 Definition 2 Processes 3 File System 4 User Interface

(2)

Rev: 1.16 Definition Processes File System User Interface Objectives Basic Definitions

Objetives

Understand what an Operating System -OS- is and its utility. Describe its different functional parts and their roles.

Understand what a process is.

Understand what a file system is.

Learn to use the basic Linux commands, the standard

Input/Output, and how to concatenate different commands.

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 3 / 28

Definition Processes File System User Interface Objectives Basic Definitions

What is an

Operating System

?

Definition

An Operating System -OS- is a program that manages the hardware resources of a computer providing services for other programs and applications. It works as an intermediate between the user and the computer hardware, facilitating its use making it more efficient.

(3)

Rev: 1.16 Definition Processes File System User Interface Objectives Basic Definitions

OS functions

The main OS functions are:

To facilitate the use of the computer and, in general, the communication computer-user

To manage and assign hardware resources (processor, memory, peripherals) to processes, and deal with conflicts.

To manage and maintain files in permanent memory devices (hard drive..)

To protect data and programs (specially important in multiuser systems)

To serve different users.

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 5 / 28

Definition Processes File System User Interface Objectives Basic Definitions

Extended Machine

The OS construct another level of abstraction presenting the user

a virtual or extended machine with a much simpler use.

It hides fine working details the user does not need to know (e.g. how to manage the read/write head of a magnetic disc)

It provides an extra set of instructions, the System Calls

They can be used by other programs or by the programmer working as an interphase with the OS

They perform useful tasks, such as Manage processes (create, cancel,...) Manage files (create, open, close)

Manage memory (load, move or free blocks of memory)

The OS converts system calls in machine instructions (the only ones that the computer executes); they are as well virtual

(4)

Rev: 1.16 Definition Processes File System User Interface Objectives Basic Definitions

Extended Machine

Sistema Operativo

Compiladores Editores Intérprete de comandos

Instrucciones en lenguaje máquina

nivelmáquina real

nivelmáquina extendida

nivelmáquina simbólica

Figure: Different levels of abstraction -machines- in a computer

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 7 / 28

Definition Processes File System User Interface Objectives Basic Definitions

Resources Administrator

It assigns hardware resources (processor, cores, memory) to each process or user

Resolve conflicts among users

Example

If various programs/users want to print at the same time, OS assigns priority and arrange them sequentially.

Example

While a process is waiting from data coming from hard disc, the OS can allow another process to use the processor

(5)

Rev: 1.16 Definition Processes File System User Interface Definitions Structure Process management

Processes

Definition

A process is a program in execution. It is the main executive

element in the computer

We can see a process as the dynamic instance of a program. Therefore it may happen that various processes execute the same program (e.g. with different input).

A computing system working is a set of one of more processes in execution according to a temporal planing established by the OS or the programmer.

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 9 / 28

Definition Processes File System User Interface Definitions Structure Process management

Elements of a process

A process can be described as:

Memory space structured in sections Processor registers.

(6)

Rev: 1.16 Definition Processes File System User Interface Definitions Structure Process management

Process structure

00000000000000000 00000000000000000 00000000000000000 00000000000000000 11111111111111111 11111111111111111 11111111111111111 11111111111111111 Datos estáticos Instrucciones Reservado Pila $SP Datos dinámicos $GP $PC 0 D ire cc io ne s de m em or ia cre cie nt es

Hueco libre (variable)

•puntero de pila$SP

•contador de programa$PC

•registro de estado$PSW

Un proceso necesita manejar registros de la CPU:

Figure: Structure of a process allocated in memory

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 11 / 28

Definition Processes File System User Interface Definitions Structure Process management

Process Features

A process can just be created by another process.

Any process (parent) can create other processes (child). Two system calls are used to create new processes:

fork: system call by which a process creates a copy of itself;

exec: Replace the contents of a running process with another program code.

The general way of launching a new program is first to fork an

existing process to create a new one, and then exec the new

(7)

Rev: 1.16 Definition Processes File System User Interface Definitions Structure Process management

Process Tree

A B C D E F

Figure: Process Tree

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 13 / 28

Definition Processes File System User Interface Definitions Structure Process management

System (

Boot

)

When turning on the computer

The program counter PC points to an address at ROM where there is a small code (BIOS -Basic Input/Output Services- in IMB PCs) that becomes the first process to be executed. This process initializes and tests the system hardware components and starts a bigger process, the

Boot Loader that loads first the OS kernel and subsequently the rest of the OS necessary to start main computer functions.

(8)

Rev: 1.16 Definition Processes File System User Interface Definitions Structure Process management

Executable File Structure

Datos estáticos Instrucciones Cabeceras Símbolos S ec ci on es

Figure: Executable File Structure

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 15 / 28

Definition Processes File System User Interface Definitions Structure Process management

Process Scheduling

The processor is the most valuable resource in the computer. It can just execute one process every time.

When a process in execution is blocked (e.g is waiting for data

coming from disc), the Scheduler suspends it and selects

another process that can be executed, so to maximize the processor use.

Each process is described by the memory space it uses and by the content of the registers in the moment it is suspended.

(9)

Rev: 1.16 Definition Processes File System User Interface Definitions Structure Process management

Scheduling: monoprogramming

0 0 0 1 1 1 00000 00000 11111 11111 00 00 00 11 11 11 00 00 00 11 11 11 0000 0000 1111 1111 0 0 0 1 1 1 0 0 0 1 1 1 00 00 00 11 11 11 00 00 11 11 00 00 00 11 11 11 sistema operativo proceso 1 proceso 2 puerto USB disco impresora dispositivos E/S CPU

inicio proc. 1 fin proc. 1

inicio proc. 2 C P U no us ad a C P U no us ad a Recursos Tiempo

Figure: Scheduling with monoprogramming

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 17 / 28

Definition Processes File System User Interface Definitions Structure Process management

Scheduling: multiprogramming

0 0 1 1 00000 00000 00000 11111 11111 11111 00 00 11 11 00 00 11 11 0000 0000 0000 1111 1111 1111 0 0 1 1 0 0 1 1 00 00 11 11 00 00 00 11 11 11 00 00 11 11 00000 00000 11111 11111 0000 0000 1111 1111 sistema operativo proceso 1 proceso 2 puerto USB disco impresora dispositivos E/S CPU Recursos inicio proc. 1

inicio proc. 2 continúa proc. 2

fin proc. 1 E/S proc. 1 E/S proc. 1

Tiempo

proc. 2 interrumpido por el s.o.

(10)

Rev: 1.16 Definition Processes File System User Interface Definitions Structure Process management

Scheduling: Round-robin

Usually there are many processes waiting to be executed, so the scheduler must apply some rule to distribute the processor time.

The Round-robin scheduling consists of assigning time

intervals T or quantums to each process and to rotate among

them

The critical decision is T: short quantums implies to loose too

much time in process change; and long ones may imply too much waiting for users.

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 19 / 28

Definition Processes File System User Interface Definitions Structure Process management

Scheduling: Process state diagram

Activo Bloqueado Listo Nonato Finalizado E/S cancelado, error fin, error distribuidor distribuidor cancelado, error distribuidor fin E/S

Figure: Process state diagram (New, Ready, Running, Blocked, Terminated)

(11)

Rev: 1.16 Definition Processes File System User Interface Definitions Structure Process management

Virtual Memory

Basically it consists of using secondary memory (hard disc) as if it was principal memory (RAM)

The OS offers a process the possibility of using much more

memory, the virtual memory than the real one, the physical

memory

This allows the system to execute much bigger programs, and more processes at the same time

The OS construct a page table for each process to traduce

virtual addresses to physical ones

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 21 / 28

Definition Processes

File System

User Interface

Definitions

Unix/LinuxFile System

File System

Definition

It is the part of the OS that controls how data is stored and retrieved.

It consists of dividing information in pieces, the files, giving them names and positions in memory, so that the information is easily identified and accessed.

Example

There are different files systems. Each OS can manage different

ones. Most common actually are: FAT32 (Windows, Linux), ext4

(Linux), NTFS (Windows), HFS+ (Mac OS X), ISO9660 (for optical

(12)

Rev: 1.16 Definition Processes File System User Interface Definitions

Unix/LinuxFile System

System calls to manage files

The main system calls to manage files are:

create/open read/write close

unlink: To delete files (removes the file name from the file system)

Note

They are OS-dependent (i.e. different for different OS), but file-system independent.

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 23 / 28

Definition Processes

File System

User Interface

Definitions

Unix/LinuxFile System

Directory Tree

shrek

ficheros

informática física ice-age

clases trabajos pelis raíz

(13)

Rev: 1.16 Definition Processes File System User Interface Definitions

Unix/LinuxFile System

Devices and files in

Unix

/

Linux

Unix/Linux manages devices (e.g. hard disc or pen-drive) as

files.

They are usually placed in the /dev directory .

System calls are the same than for the ordinary files.

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 25 / 28

Definition Processes

File System

User Interface

Definitions

Unix/LinuxFile System

Mount point

When installing a new device, the file system uses a Mount

Point that it is just a directory in the system where the new

devices is mounted.

The user sees that the directories and files in the device appear in a previously empty directory of the file system.

(14)

Rev: 1.16 Definition Processes File System User Interface Concept Shell Interface

User Interface

The User Interfaces is a part of the OS that allows interaction

with the user through peripherals (keyboard, screen...) The most common UI are:

Command Line Interface: Orders are typed with the keyboard in a terminal, the OS interpret those commands looking for the programs to execute and directing results to output devices.

Graphical user interfaces (GUI) (e.g Windows). Mouse and keyboard are use to select icons in the screen and the output is graphical output on the computer monitor.

Touchscreens. Input touching a screen (tablets, mobiles...)

Ra´ul Dur´an D´ıaz,Juan Ignacio P´erez Sanz,Alvaro Perales Eceiza´ 3. Operating Systems 27 / 28

Definition Processes File System User Interface Concept Shell Interface

Shell Program

It is a very complete Interface program that works as a

command-line interface. The user types commands and the Shell

execute them. Some of its features are: Standard Input/Output;

Command concatenation, pipeline;

Environment variable (PATH, HOME...) Some basic commands:

References

Related documents

Kommunikation som inte är tydlig och förståelig kan leda till att målet inom kompetensbeskrivningen för sjuksköterskor inom palliativ vård (2008), som säger att varje

Las características particulares de los eventos secos y húmedos ocurridos en la región de la cuenca hidrográfica de la laguna Sauce Grande, durante el período 1971- 2010, se

The study was aim to investigate the effects of continuous PCBs exposure on optomotor response (OMR) and retinal photoreceptor cell development-related gene expression in

Kernel threads can access both kernel virtual memory and, if a user process is running, the user virtual memory of the running process.. However, even in the kernel, an attempt

[r]

Hardinge Lathes Page 9 Square Shank Tool Holders: Left- & Right-hand Y-Axis.. CW CW1 CH1 T CH L S H

A hypervisor allows multiple virtual machines on the same hardware platform and provide the management interface between each virtualized operating system and the underlying CPU,

 Server System Reports and Operating Systems– physical and virtual memory stats, CPU usage, interface utilization, file system utilization, configuration reports and change alerts,