YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: ppt slides

1Software Techniques Lecture 1

Outline1. Course Information2. History of Operating Systems3. Basic Components of OS

Lab 1Become familiar with Linux

ReadingsChapter 1

Operating Systems

Tim JiLecture 1

Page 2: ppt slides

2Software Techniques Lecture 1

1 Course Information

• Official Course Outline– On course webpage, MS Word document

• Course Objectives/Learning Outcomes– Understand OS algorithms

– Be able to write multitasking programs with a variety of inter-process communication methods

– Be able to write scheduling, paging algorithms

• Textbook: Tanenbaum, “Modern Operating Systems” 2nd Edition, Prentice Hall

Page 3: ppt slides

3Software Techniques Lecture 1

Page 4: ppt slides

4Software Techniques Lecture 1

Course Information (2)

• Instructor– Name: Tim Ji– Email tji AT conestogac.on.ca– Office: 2A503, x2230– Office hour: Drop by my office or by appointment

• Grading– 3 tests, 20% each: 60%– Assignments + Labs: 40%

• Assignments– Due in class at the end of lecture, 20% reduction in the

assignment mark for each school day it is late. – The assignments must be your own work. Cheating/copying

other people’s files will result in both papers receiving zero.

Page 5: ppt slides

5Software Techniques Lecture 1

Course Information (3)

• Labs– Lab tasks will be demonstrated in the following week lab, and lab

reports must be submitted by the end of the lab. You have 1 week to finish the lab task.

• Course website– http://www.conestogac.on.ca/~tji/os– Announcements, assignments, lecture handouts, etc.– Check it out at least once per day.

• Study to pass– You have to pass both the tests portion and the assignments portion

• Assignments/Labs marking– Demonstrate your task in lab– Answer questions regarding to your own task– Programming style of printouts of your source code, for

programming assignments/labs

Page 6: ppt slides

6Software Techniques Lecture 1

Introduction to Operating Systems

• Topics:– Role and purpose of the operating system

– History of operating system development

– Functionality of a typical operating system

• Learning Objectives:– Explain the objectives and functions of modern operating

systems.

– Describe how operating systems have evolved over time from primitive batch systems to sophisticated multiuser systems.

– Describe the functions of a contemporary operating system with respect to convenience, efficiency, and the ability to evolve.

Page 7: ppt slides

7Software Techniques Lecture 1

Early Computers

• First Computer– Charles Babbage (1791-1871) designed the first true digital

computer called the analytical engine.

– That was purely mechanical and intended to do math operations

– The engine was supposed to be made of brass, and steam powered

– He did not actually built the machine but inspired others in the field.

Page 8: ppt slides

8Software Techniques Lecture 1

Early Computers

• Babbage also thought of the concept of software

• And hired the first programmer (Lady Ada, Countess of Lovelace) for his analytical engine

Page 9: ppt slides

9Software Techniques Lecture 1

Current Computer Systems

• A computer system consists of– hardware

– system programs

– application programs

Page 10: ppt slides

10Software Techniques Lecture 1

What is an Operating System (1)

• Microsoft Glossary:– The software that controls the allocation and usage of hardware

resources such as memory, central processing unit (CPU) time, hard disk space, and peripheral devices (like speakers or a mouse).

– The operating system is the foundation software on which programs, such as Word or Excel, depend.

– An example of an operating system is Microsoft Windows® XP.

Page 11: ppt slides

11Software Techniques Lecture 1

What is an Operating System (2)

• Provide a service for clients - a virtual machine (top-down view)

An operating system is a layer of the computer system (a virtual machine) between the hardware and user programs.– Multiple processes

– Multiple address spaces

– File system

Page 12: ppt slides

12Software Techniques Lecture 1

What is an Operating System (3)

• Resource manager (bottom-up view)An operating system is a resource manager.  Resource management includes– Transforming resources - to provide an easier to use version

of a resource – Multiplexing resources - create the illusion of multiple

resources – Scheduling resources - when and who gets a resource

• The hardware resources it manages include– Processors - process management system – Memory - memory management system – I/O devices - I/O system – Disk space - file system

Page 13: ppt slides

13Software Techniques Lecture 1

What is an Operating System (4)

• The hardware resources are transformed into virtual resources so that an operating system may be viewed as providing a virtual computers, one to each user. A virtual machine (top down view) consists of– Processes - virtualization of the computer including a virtual

processor that abstracts the cpu - user mode instruction set + system calls

– Virtual memory - virtualization of physical memory

– Logical devices - virtualization of physical devices

– Files - virtualization of disk space

Page 14: ppt slides

14Software Techniques Lecture 1

What is an Operating System (5)

• The general functions of an operating system– Allocation - assigns resources to processes needing the

resource – Accounting - keeps track of resources - knows which are

free and which process the others are allocated to. – Scheduling - decides which process should get the resource

next. – Protection - makes sure that a process can only access a

resource when it is allowed

• Basic Functions– Process management – Resource management

• Device managment • Memory management • File management

Page 15: ppt slides

15Software Techniques Lecture 1

History of Operating Systems (1)

• First generation 1945 - 1955– Technology: vacuum tubes & plugboards– Programming: setting some switches

– Programming language: machine language

– Tasks: tables of sine, cosine, logarithms

– OS: none

Page 16: ppt slides

16Software Techniques Lecture 1

A Famous Remark

• "I think there is a world market for maybe five computers."

– Thomas Watson, chairman of IBM - 1943

Page 17: ppt slides

17Software Techniques Lecture 1

History of Operating Systems (2)

• Second generation 1955 – 1965– Technology: Transistors

– Programming: Punched cards

– Programming languages: FORTRAN & Assembly

– Tasks: Scientific

– Computer: Mainframes

– OS: Batch system

• Universities started to buy computers (millions $)

Page 18: ppt slides

18Software Techniques Lecture 1

– bring cards to IBM 1401 machine (good at card reading)– read cards to tape– put tape on IBM 7094 which does computing– put tape on IBM 1401 which prints output offline

Early Batch System

Page 19: ppt slides

19Software Techniques Lecture 1

Famous Remarks

• "I have traveled the length and breadth of this country and talked with the best people, and I can assure you that data processing is a fad that won't last out the year.“– The editor in charge of business books for Prentice Hall

- 1957

Page 20: ppt slides

20Software Techniques Lecture 1

History of Operating Systems (3)

• Third generation 1965 – 1980– Technology: ICs

– Programming: Punched cards

– Programming languages: FORTRAN & Assembly

– Tasks: Scientific & commercial

– Computers: IBM 360, DEC PDPs

– OS: Multiprogramming/timesharing, spooling

• OSes Developed:– MULTICS (father of all modern OSes)

– UNIX (System V, BSD)

– POSIX (by IEEE)

– MINIX (by Tanenbaum)

– Linux (derived from MINIX)

Page 21: ppt slides

21Software Techniques Lecture 1

Famous Remark

• “There is no reason anyone would want a computer in their home.“– Ken Olson, president, chairman and founder of Digital

Equipment Corp. - 1977

Page 22: ppt slides

22Software Techniques Lecture 1

History of Operating Systems (4)

• Fourth generation 1980-Present– Technology: VLSI

– Programming: High level

– Programming languages: C/C++, Java, ……

– Computer: PC

– OS: Windows, MacOS, Linux ……

• Cheap PCs

Page 23: ppt slides

23Software Techniques Lecture 1

Famous Remark

• “We don't see Windows as a long-term graphical interface for the masses.“– A Lotus Software Development official, while

demonstrating a new DOS version - 1989

Page 24: ppt slides

24Software Techniques Lecture 1

The Operating System Zoo (1)

• Mainframe operating systems– Room-size computers

– High I/O capacity

– Offers:• Batch processing (no interaction, such as large reports)

• Transaction processing (large number of small requests)

• Timesharing (multiple users sitting in front of clients)

Page 25: ppt slides

25Software Techniques Lecture 1

Famous Forcast

• "Computers in the future may weigh no more than 1.5 tons." – Popular Mechanics, forecasting the relentless march of

science, 1949

Page 26: ppt slides

26Software Techniques Lecture 1

The Operating System Zoo (2)

• Server operating systems– Offer services like print, file, or web– UNIX, Windows 2000, Linux

• Multiprocessor operating systems– Parallel computing

• Personal computer operating systems– Single user with a good GUI, such as Windows 98,

Windows 2000, Macintosh OS, Linux

Page 27: ppt slides

27Software Techniques Lecture 1

The Operating System Zoo (3)

• Real-time operating systems– E.g. industrial process control systems where each job must be

completed in the specified time.

– Hard real-time (nuclear reactor control systems) or soft-real time systems (e.g multimedia systems) depending on the acceptance of missing deadlines

• Embedded operating systems:– Real-time systems with some resource constraints like memory,

CPU, power.

• Smart card operating systems– Extremely primitive OS running on credit card sized devices with

a CPU.

Page 28: ppt slides

28Software Techniques Lecture 1

Computer Hardware

• Components of a simple personal computer

Monitor

Bus

Page 29: ppt slides

29Software Techniques Lecture 1

CPU

• Brain of the computer– ALU (Arithmetical- Logical Unit)– CU (Control Unit, fetch-execute-decode instructions)

• Has a certain set of instructions it can recognize and execute

• Basic CPU cycle– Fetch the next instruction– Decode it to determine its type and operands– Execute it – …..

• Programs are list of instructions executed by the CPU

• When the computer powers up, CU of CPU starts the fetch-decode-execute cycle

• Instructions may be OS instructions or other programs

Page 30: ppt slides

30Software Techniques Lecture 1

CPU Modes

• A bit in PSW controls the mode• Kernel Mode :

– CPU can execute every instruction in its instruction set– CPU can use every feature of the hardware– OS runs in kernel mode

• User Mode:– Only a subset of instructions can be run– And a subset of hardware features are accessed– Generally all instructions involving I/O and Memory protection

are disallowed in that mode

• To obtain OS services, a user program must make a system call that traps into kernel mode and invokes the OS

• Trap instruction switches from user mode to kernel mode and starts the operating system (system calls and errors such as division by zero causes trap instructions)

Page 31: ppt slides

31Software Techniques Lecture 1

Pipelining

• Parallelize the fetch, decode, execute sequence

• Three stage pipeline : While executing instruction N, decode instruction N+1, and fetch instruction N+2

• What happens when a conditional branch occurs in an instruction?

Page 32: ppt slides

32Software Techniques Lecture 1

CPU Pipeline

(a) A three-stage pipeline (three instructions processed in 1 cycle)

(b) A superscalar CPU (with multiple execution units)

Page 33: ppt slides

33Software Techniques Lecture 1

Pipelining

Instruction N+2

Instruction N+3

Instruction N + 4

One CPU Cycle

Instruction N + 1

Instruction N

Fetch NDecode NFetch N+1

Execute NDecode N+1Fetch N+2

Execute N+1Decode N+2Fetch N+3

Execute N+2Decode N+3Fetch N+4

Page 34: ppt slides

34Software Techniques Lecture 1

Memory Hierarchy (1)

• Typical memory hierarchy– numbers shown are rough approximations

Page 35: ppt slides

35Software Techniques Lecture 1

Memory Hierarchy

• Magnetic Tape : – Backup purposes and for storing very large data sets.

– One dimensional, only sequential access is possible

– Reliable (no tape crashes, or time based data corruption)

– Was the main data storage medium of the past

• Optic CDs:– Faster than tape

– Used for permanent storage (now rewritable)

Page 36: ppt slides

36Software Techniques Lecture 1

Memory Hierarchy

• Magnetic disks:– Are faster than tapes and CDs

– They are the main storage medium these days

– Data stored in concentric cylinders

– Disk head moves in discrete steps

– Each position of the disk head identifies a track (divided into multiple sectors, typically 512 bytes)

– Rotates continuously with a certain speed (e.g. 7200 rpm)

Page 37: ppt slides

37Software Techniques Lecture 1

Memory Hierarchy

• Disks and tapes are mechanical devices, therefore they are slow compared to (RAM and Cache)

• Main Memory (Random Access Memory) : – Volatile

– Much Much faster than magnetic disks but more expensive too

• Cache:– Faster than RAM and more expensive

– CPU requests first go to cache, and if they are there (cache hit) then fine, if not there (cache miss) then RAM is accessed

– There can be multiple cache levels

– Cache is divided into cache lines (usually 64 bytes at each line)

Page 38: ppt slides

38Software Techniques Lecture 1

Memory Hierarchy

• Registers– They are the fastest accessible memory locations

– Placed at the CPU.

– They are usually of size 32 bits, or 64 bits depending on the CPU type

Page 39: ppt slides

39Software Techniques Lecture 1

Memory Hierarchy

• Read Only Memory (ROM)– Write once, read many times

– Low level I/O cards

– Code for starting the computer

• Electrically Erasable Rom (EEPROM)– Non volatile

• Flash RAM– Non volatile

Page 40: ppt slides

40Software Techniques Lecture 1

Memory Hierarchy

• CMOS (Complementary Metal Oxide Semiconductor)– Volatile but can be sustained with mother board battery for years.

– May give checksum errors when being corrupted

– Very small, 64 bytes.

– Holds the current time and date, configuration parameters (like which disk to boot from etc.)

Page 41: ppt slides

41Software Techniques Lecture 1

Yet another famous quote!

• "640K ought to be enough for anybody." – Bill Gates, 1981

Page 42: ppt slides

42Software Techniques Lecture 1

I/O Devices

• An input device transfers data from a mechanism like keyboard, mouse, touch screen, or microphone into a CPU register. CPU will then store the data into Main Memory

• For output devices, CPU fetches the information from main memory to its registers and transfers this information via the bus to an output device like screen, speaker, or printer.

• Communication devices : serial and parallel ports, infrared transmitter/receivers, wireless network cards, network interface cards

Page 43: ppt slides

43Software Techniques Lecture 1

CPU DISK CONTROLLER

DISK PRINTER

PRINTER CONTROLLER

MEMORY

MEMORY CONTROLLER

•Device controllers have microprocessors.•They can work in parallel. •They can tell CPU when they are done.

Page 44: ppt slides

44Software Techniques Lecture 1

How I/O Can Be Done

• Three methods:– Busy waiting through system call

– Interrupt

– DMA (Direct Memory Access)

Page 45: ppt slides

45Software Techniques Lecture 1

Lab 1: Get Familiar with Linux

• Introduction to Linux• Lab material is available on the course webpage• Follow the lab task specifications -- your marks

depend on it.

Page 46: ppt slides

46Software Techniques Lecture 1

Readings

• Tanenbaum, Chapter 1