lecture 1 operating systems conceptsilisei/os -lecture_01 - operating... lecture 1 operating systems...

Post on 19-Jan-2019

220 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Operating systems

Lecture 1

Operating systems concepts

ProcessesSept.2018

Narcis ILISEI

Welcome

⚫ Willkommen

⚫ Bienvenue

⚫ Bienvenidos

⚫ Velkommen

⚫ Baruch haba

⚫ Vítejte

⚫ Irashaimasu

⚫ Benvenuto

⚫ Huan yin

⚫ Bine ati venit

⚫ Esiet sveicinati

⚫ Sveiki

⚫ Dobrodoshli

⚫ Välkommen

Hos geldiniz

Kalos orisate

Isten hozta

Vitajte

Merhaba

Witaj

Dobro pozhalovat

Tere tulemast

Bem-vindo

Dobre doshal

Swaagatam

Dobrodošel

Hwangyong-hamnida

Narcis ILISEI

⚫ Telecommunications Engineer

⚫ BSc in 1999, MSc, in 2000

⚫ Tech. Univ. Iasi, Romania

⚫ 1999-2000 - Teaching assistant

⚫ C++, VHDL

⚫ 2000-2010 - R&D Engineer

⚫ Agilent Technologies, Böblingen

⚫ Embedded Software

⚫ High Speed Measurement Instruments

⚫ Since 2010 - Software consulting, Inatech

NI – cont.

⚫ Experience with various operating systems

Autosar, ThreadX, Windows(...), Linux (...),

VxWorks, pSOS, WindowsCE, eLinos,

eCOS, RTLinux, Android, iOS

Course format

⚫ Lectures with

⚫ Theory

⚫ ... BREAKs

⚫ Practical examples, exercises

⚫ ...more Breaks

⚫ Questions ! Interactivity is important! ⚫ Small Homeworks

⚫ Final exam

Further documentation

⚫ Recommended book:

⚫ „Modern operating systems“, 3rd or 4th editions

– Andrew S. Tanenbaum

⚫ Alternatives:

“Modern operating systems:Global Edition”

“Moderne Betriebssysteme”

⚫ Wikipedia

⚫ Microsoft MSDN

Summary

⚫ What is an OS ? Why study OSes?

⚫ Short OS history

⚫ OS reduce complexity

⚫ OS Concepts overview

⚫ Exercise: Install an OS

What is an OS?

What does it do?

⚫ A layer of software that manages the

computer / machine

⚫ Offers an nice interface to users

⚫ Offers a simplified machine to programs

⚫ Reduces complexity for programmers

⚫ Manages the resource of the computer

What has a computer to

manage

⚫ A modern computer consists of:

⚫ One or more processors

⚫ Main memory

⚫ Disks

⚫ Various input/output devices: (HID, lan, camera...)

⚫ Application Software

⚫ Managing all these components requires a

layer of software – the operating system

OS turns ugly/complex HW

into a beautiful interface

Picture(c): “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Course summary

• OS concepts

– process, threads, locks, IPC

– IPC, Deadlocks

– Scheduling

– Memory management

– File systems

– I/O

• Example OSes:

– Linux, Android, iOS, RTA-OSEK, Windows

Why OS special course?

⚫ OS offers a Virtual Machine to programmers

⚫ Using OS makes programmer’s life easy

⚫ Required knowledge for system design

⚫ The OS concepts are complex

⚫ OSes are great programming examples

⚫ Basic and Required knowledge for computer

science engineers

Summary

⚫ What is an OS ? Why study OSes?

⚫ OS history

⚫ OS reduce complexity

⚫ OS Concepts overview

⚫ Install an OS

History: Computer and OS

Generations

⚫ Computers:⚫ (1945–55) Vacuum Tubes

⚫ (1955–65) Transistors and Batch Systems

⚫ (1965–1980) ICs and Multiprogramming

⚫ (1980–Present) Personal Computers

⚫ (2000- Present) Mobile Computers

⚫ OSes:⚫ Phase 1: until 1970: HW expensive, no OS,

⚫ Phase 2: 70’s: Multiprogramming, complex OS needed

⚫ Phase 3:1980–present: many OSes that better fit specific needs

⚫ Phase 4: 90’s–present: Distributed systems

⚫ Phase 5: 2000–present: Mobile systems

Why history ?

• Techniques change greatly over time but

principles are more resistant,

• Some old concepts reappear in newer form

later

⚫ In this course - more emphasis on key

concepts, less likely to change

Phase 1: until 1970

(a) Programmers bring cards to 1401.

(b)1401 reads batch of jobs onto tape. Operator carries input tape to 7094.

(d) 7094 does computing. (e) Operator carries output tape to 1401. (f) 1401 prints output

HW Expensive

⚫ ENIAC ⚫ 1945-1955, Eckerd and Mauchly

⚫ One room, 30 tonns, x100 KWH

⚫ Batches of work⚫ complexity increased, protection needed

Picture(c): “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Batch Jobs on cards

Structure of a typical job.

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Phase2: ‘70s

HW expensive => Multiuser

⚫ MULTICS – OS (released in 1969)

⚫ OS 360 released

⚫ Disk drives, 140MB ~”washing machine”

⚫ 1.7 bytes/sq inch - 164 GB/sq inch today

Phase 3: 1980 - today

HW Cheap – Multi computers / user

⚫ Humans expensive

⚫ OSes became simple (subroutine, single

user)

⚫ Late 90’s , 2000 – OS got big again

⚫ Abstraction / simplifications still needed ->

OSes

⚫ Today More than 1computer/human

Some past and present OSes

⚫ Multics

⚫ Unix

⚫ DOS, MS-DOS

⚫ Unix: Linux (many), BSD, Sun OS, HPUX

⚫ Apple - OS X (based on BSD)

⚫ Windows (95, 98, 2000, XP, Vista, 7, 8.x, 10)

⚫ Mobile: Android (based on Linux), iOS, Windows, Linux

⚫ Embedded (many): RTA, VxWorks, WindowsCE, OSEK...

⚫ Real time: RTLinux, QNX

⚫ Smart card OSes

Summary

⚫ What is an OS ? Why study OSes?

⚫ OS history

⚫ OS reduces complexity

⚫ OS Concepts overview

⚫ Install an OS

OS is a solution against

complexity

⚫ We need to write a single program that

handles many independent activities ?

⚫ Every program needs to support different

types of HW?

⚫ Acceptable that a buggy program crashes the

system?

⚫ Should every program have access to

complete HW?

Computer HW review

⚫ In the beginning it was a mechanical

computer

⚫ A long time after, electronic tubes

⚫ Then transistors

⚫ Performance governed by Moore‘s Law

⚫ ...8080, Z80, 8086, 286,386,Pentium,

...Core2

⚫ Today: multicore chips; low power devices

⚫ CPUs

⚫ Memory

⚫ Peripherals

⚫ I/O, Monitor, Audio

⚫ Interfaces

HW structure

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

HW StructureBecomes complex as one goes into details

Example PC mainboard

⚫ CPU

⚫ Memory

⚫ Peripherals

CPU – central processing unit

CPU’s tasks:

Fetch instruction from memory

Decode and execute instruction

Write results to Memory or to I/O

Pipeline: reduces idle times

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

1. CPU is complex!

OS helps

⚫ Instruction decoder

⚫ ALU, Multiplicator,...

⚫ Memory access, Bus

⚫ Multi core, Hyperthreading

RISC

Pipeline, Superscalar

Reordering

Branch prediction, speculation

Dynamic compilation

Exception handling

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Various Memory Types Access time varies greatly!

Holds data and programs

Present at different levels in the HW structure

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

2. Memories are complex

OS helps!

⚫ Registers – N* x64 bit

⚫ L1 Cache – N* MB

⚫ L2 Cache – N* MB

⚫ RAM (DRAM,SRAM...) – N* GB

⚫ Flash/ EEPROM

⚫ Hard Disk, Tape –N* TB

Cache hit/miss

Addressing, latency,

Protection,

Exception handling

Interleaving

Bus protocols

Network

RAID

Peripherals

⚫ Buses: Cache, Memory, Bridges

⚫ PCI, PCIe, ..., ISA,

LPC...

⚫ USB, Firewire

⚫ RS232

⚫ Plug and Play

⚫ LAN, WLAN

⚫ Infrared

Bus protocols

3. System HW is complex!

OS helps again!

⚫ CPU fetches instructions from Memory

⚫ Decodes, executes

⚫ Results to memory or peripherals

⚫ Many interrupts occur. Components compete

for CPU cycles

4. Complex HW diversity

OS offers a simple interface

⚫ Different CPUs: pentium, ARM, PowerPC,...

⚫ Different memorys, disks

⚫ Types of Devices: mice, KB, Camera,

Fingerprint readers...

⚫ Networking environments: cable, DSL,

UMTS,Wireless

⚫ ...

5. Complexity of requirements

OS helps here too!

⚫ Example Pathfinder

⚫ HW: 20MHz,128MBRam

⚫ Many instruments, batteries,

solar panel

⚫ Many programs, some

unstable

⚫ Reset button inaccessible

⚫ Critical:

⚫ Always able to receive cmds

from Earth + debug

⚫ Track Earth orbit

⚫ Stop before hit a rock...

Conclusion:

OS helps against complexity

⚫ We need to write a single program that

handles many independent activities ?

⚫ Every program needs to support different

types of HW?

⚫ Acceptable that a buggy program crashes the

system?

⚫ Should every program have access to

complete HW?

HW review

⚫ HW = CPU + Memory + Peripherals + Buses

⚫ HW complexity hidden inside OS

⚫ HW related problems solved by OS:

⚫ Support for HW access: “Device driver”

⚫ Memory protection against other processes

⚫ HW resource management for the benefit of SW.

Summary

⚫ What is an OS ? Why study OSes?

⚫ OS history

⚫ OS reduce complexity

⚫ OS Concepts overview

⚫ Install an OS

OS Concepts overview

⚫ OS Structure

⚫ Kernel / microkernel

⚫ Library

Process

⚫ Thread

⚫ Process table

⚫ Special process - Shell

⚫ Files

⚫ Directory, file descriptor

System call

I/O

IPC

Signal, Semaphore, queue,

events

Memory management

Virtual memory

Address space

Virtualisation

OS structure

⚫ Monolithic systems – basic structure:

⚫ A main program that invokes the requested

service procedure.

⚫ A set of service procedures that carry out the

system calls.

⚫ A set of utility procedures that help the

service procedures.

OS Structure

Monolithic kernel

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Microkernel

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Process

⚫ Process = One running program

⚫ Has its own memory space.

⚫ Events which cause process creation:

⚫ System initialization.

⚫ Execution of a process creation system call by a

running process.

⚫ A user request to create a new process.

Process table

⚫ Process table administrative info

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Processes

A process tree. Process A created two child processes, B and C. Process B created three child processes, D, E, and F.

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Process management API

⚫ Unix

⚫ fork()

⚫ execve()

⚫ exit()

⚫ wait()

Windows

CreateProcess()

-

ExitProcess()

WaitForSingleObject()

Some of the major POSIX system calls.

System Calls for Process Management

TRY this!

Source: “Modern operating systems” - A.Tannenbaum, 3rd edition, Pearson Prentice Hall

Process exampleBackground Service

Main process

⚫ Start, init

⚫ Start child process in

background

⚫ End

⚫ Child process

⚫ Start

⚫ While(true)

⚫ Work()

Int close_console_window()

pid_t pid = fork();

if(pid < 0) return Err;

if (pid == 0) /* child */fclose(stdin);

fclose(stderr);

return RC_OK;

else /*parent*/

exit(0);

Summary

⚫ What is an OS ? Why study OSes?

⚫ OS history

⚫ OS reduce complexity

⚫ OS Concepts overview

⚫ Install an OS

Todo: Install an OS + prepare work environment

+ shell commands

⚫ OS installation

⚫ OS basic configuration

⚫ Basic command line work

⚫ C compiler

⚫ Debugger

⚫ Hello world

⚫ Basic OS commands

Lab : „Hello World“

Linux, Android, Windows

⚫ Goal is to have one or several systems

suitable for tests and mini homeworks

⚫ Candidates:

⚫ Linux + command line gcc + gdb GUI

⚫ Windows + Visual Studio

⚫ Android + Eclipse IDE

Basic Bash commands

⚫ man bash

⚫ mkdir, rm, ls, cp, mv, ln

⚫ chmod, chown

⚫ ps, kill, nice

⚫ cat, less, more

⚫ mount, umount

⚫ echo

⚫ exec

⚫ find

yes

pwd, date, export

Whoami

Grep

Df, du

Mkisofs

Ifconfig

Ping

....

Summary

⚫ What is an OS ? Why study OSes?

⚫ OS history

⚫ OS reduce complexity

⚫ OS Concepts overview

⚫ Install Tools

top related