Last Week Logic gates are built out of transistors There are many - - PDF document

last week
SMART_READER_LITE
LIVE PREVIEW

Last Week Logic gates are built out of transistors There are many - - PDF document

10/26/2009 Last Week Logic gates are built out of transistors There are many different logic gates NAND is functionally complete Digital circuits process data using gates Half and full adder 1 10/26/2009 This week


slide-1
SLIDE 1

10/26/2009 1

Last Week

 Logic gates are built out of transistors  There are many different logic gates  NAND is functionally complete  Digital circuits process data using gates  Half and full adder

slide-2
SLIDE 2

10/26/2009 2

This week

 Software  Operating systems  Kernels  Shells

slide-3
SLIDE 3

10/26/2009 3

Programs

 Programs tell the computer what to do  Very earliest computers had fixed

programs

 Program was part of computer  like e.g. a digital calculator  Programming involved physical redesign

Stored programs

 Since Manchester ―Baby‖ (1948)  Program is data  Program can now be processed by

computer

 Programmer can easily change it  Computer can change its own programs

slide-4
SLIDE 4

10/26/2009 4

Hardware & Software

 Hardware: physical parts of the

computer

 e.g. processor, RAM, mass storage  to improve you replace  Software: programs stored on

computer

 e.g. operating system, browser,  to improve you can update

Firmware

 Computer program run on non-CPU

hardware

 Can be updated by software  Examples  BIOS (Basic Input/Output System) controls

bootup of PC

 Optical drive (e.g. DVD) controller, can be

updated as technology evolves

 Halfway between software and

hardware

slide-5
SLIDE 5

10/26/2009 5

Software

 System software  Basic operations of computer  Operating system: manages all activity  Utility software: supports routine tasks

○ e.g. defrag, virus scan, compression, ...

 Application software: supports users’

needs

 e.g. web browser, word processor

slide-6
SLIDE 6

10/26/2009 6

Operating Systems

 Software that manages activities and

resources of computer

 Windows, Linux, OS X, ...  Allows user to start programs  Environment for programs to run  Kernel surrounded by shell

Operating systems

 What is an operating system?

 It is a program that manages all other programs. These

  • ther programs or applications make requests from the
  • perating system (ex. Open program).

 PC Operating systems ○ DOS ○ Windows 3.1, 95, 98, NT, 2000,ME, XP, Vista ○ Linux  Mac Operating systems ○ OS 8.6, 9.0, 9.1, X.2 , X.4…

slide-7
SLIDE 7

10/26/2009 7

Why Study Operating Systems?

 Most likely you won't write an OS, so why

study them?

 Primary intersection point:

○ It draws on many CS areas - software engineering,

computer architecture, data structures, networking, algorithms.  Learn programming techniques:

○ One can apply data structures, conflict resolution,

concurrency issues, resource management, etc., used in OS to other areas.  "Grungy" things sometimes do require modifications

to OS.

○ You can't do this if you don't understand them!

 Curiosity – ―look under the hood.‖

What is an Operating System?

 An Operating System (OS) is a program that controls

the execution of computer programs and act as the interface between the user and the hardware.

 An OS functions as:  A resource manager

○ It manages and allocates resources such that the computer

hardware can be used in an efficient manner.

○ Examples of resources: processes, CPU(s), memory, file system,

networking, etc.  A virtual machine:

○ OS hides the details of the underlying hardware ○ OS provides a common API to applications and services.

 An OS makes the machine convenient and efficient to

use.

slide-8
SLIDE 8

10/26/2009 8

History of Operating Systems.

 Once upon

a time …

 Human

Computer

History of Operating Systems (cont)

 First

generation 1945 - 1955

 vacuum

tubes, plug boards

 ENIAC

(mid- 1940’s)

 Just part of

it!!

 Single program execution  Why?  Hardwire “programming”  Programming slow, not “offline”!

Plug board and punch cards.

No programming language.

 Programmer spent quite a lot

time to find the real “Bug”.

slide-9
SLIDE 9

10/26/2009 9

History of Operating Systems (cont)

 Second generation 1955 - 1965

 transistors, batch systems.

 Early batch system (overlapped CPU & I/O operations)

 Buffer slow I/O onto fast tape drives connected to CPU, replicate

I/O devices.

 Spool data to disk.

 Programming languages:

Fortran or assembler (on punch cards!).

 Two main applications:

Scientific.

Data processing.

History of Operating Systems (cont)

 Third generation

1965 – 1980

 IBM 360 series (mid-

1960s)

 Multi-programming

systems:

 Run several programs

at the same time.

 Spooling as jobs

finished.

 New problems:

 Response time.  Thrashing.  File-systems.

slide-10
SLIDE 10

10/26/2009 10

History of Operating Systems (cont)

 Interactive timesharing systems:  Lots of cheap terminals and one computer

○ All users interact with the system at once ○ Debugging is much easier

 Disks are cheap so put programs and data online

○ 1 punch card = 100 bytes

 New problems:

○ Need pre-emptive scheduling to maintain adequate

response time

○ Need to avoid thrashing (swapping programs in and out

  • f memory too often)

○ Need to provide adequate security measures

 UNIX developed at Bell Labs (Thompson, Ritchie)

History of Operating Systems (cont)

 Fourth generation 1980 – present  Personal computing  CPUs are cheap enough for everyone, yet powerful

enough to be useful.

SUPERBOWL IBM 8086 vs.

The only real competitor left… There can be only one…IBM PC

slide-11
SLIDE 11

10/26/2009 11

OS’s: The Bad News...

 Modern operating system are:  Enormous:

○ Linux v2.6 – approx. 5.9 million lines of code (128MB

RAM)

○ Win2000 - approx. 35 million lines of code (64MB RAM) ○ WinXP – approx. 40 million lines of code (128MB RAM) ○ Win2003 – approx 50 million lines of code (256MB

RAM)  Complex:

○ Poorly understood – too large for one person to

comprehend.  (Always) full of bugs and (often) unreliable.  Dependent on hardware in strange ways (makes

porting difficult).

Commercial-Released O/S

A commercial-release operating systems is any operating system which has all of the following attributes:

 It costs money, typically more than $50  Source code for the system is not available  There are strict limits as to how the system

may be copied.

 Consequently, Windows, MacOS, DEC

Ultrix, Solaris, OS/2, and other similar platforms are commercial operating systems.

slide-12
SLIDE 12

10/26/2009 12

The problems

 The needs of the computer user have to

be balanced with the companies need for profit.

 Here is some of the issues:  Slow release pattern  High cost  Tech Support?  Lack of source code availability  Planned obsolescence of hardware  Crash-prone

slide-13
SLIDE 13

10/26/2009 13

Windows

 Hybrid kernel (NT)  System libraries: C:\windows\system32\  Shells: cmd.exe (CL) and explorer.exe

(GUI)

 System tools: cmd.exe

slide-14
SLIDE 14

10/26/2009 14

The Unix Operating System

 The UNIX operating system was designed to let a

number of programmers access the computer at the same time and share its resources.

 Bell Laboratories created the UNIX OS in 1969.  There goals were to design an operating system to

satisfy the following objectives:

 Simple and elegant  Written in a high level language rather than assembly

language (It is written in C)

 Allow re-use of code

The Unix Structure

 Structure: Kernel and shell

 kernel (in assembly language, small)  shell (in C).

 The benefit of this structure is that UNIX is highly

customizable and new features are relatively simple to add.

slide-15
SLIDE 15

10/26/2009 15

What is UNIX?

29

The Unix Kernel

 This

is the heart

  • f

the UNIX Operating System.

 The kernel is at the core of each UNIX

system and is loaded in whenever the system is started up

 The kernel creates the same virtual

machine

30

slide-16
SLIDE 16

10/26/2009 16

The Unix Kernel

 It performs the tasks that create and maintain

the UNIX environment managing the entire resources of the system. It:

  • Manages the machine's memory
  • Schedules the work done by the CPU
  • Organizes the transfer of data from one part of

the machine to another

  • Accepts instructions from the shell and carries

them out

  • Enforces access permissions
  • Keeps

track

  • f

the disks, tapes, printers, terminals, communication lines etc attached to the computer.

 You do not need to know anything about the

kernel in order to use a UNIX system

31

The Kernel

 Core of the operating system  Coordinates activity of CPU, memory & I/O  Provides basic services to other software  Open a file  Create a directory  Connect to network host  ...

slide-17
SLIDE 17

10/26/2009 17

Parts of the Kernel

 File manager  Where files are stored, and free space  Which users allowed access  Device drivers  Communicate with attached I/O devices  Memory manager  Assign RAM space to individual tasks  Paging: when RAM is full it can overflow

  • nto hard disk

Kernels In Action

 Optimised for different applications  Space: embedded devices (PalmOS)  Reliability: no-access environments

(VxWorks)

 Real-time response: guidance

systems (QNX)

 Scalability: mainframes (z/OS)

slide-18
SLIDE 18

10/26/2009 18

Kernel Design

 Monolithic: a single kernel does all the work  Microkernel: a simple kernel delegates

services to many servers

 Hybrid: core services in kernel + some

servers

The Shell

 Interface between

user and kernel

 Command-line shell  GUI (Graphical User

Interface) shell

slide-19
SLIDE 19

10/26/2009 19

The Shell

 The Shell is a program that provides an interpreter

and interface between the user and the UNIX Operating System.

 Upon login the user is placed in their own shell

which prompts for and reads commands.

 The commands are translated and passed on to

the kernel for execution and the results are then displayed at the terminal.

 Input can be via the keyboard or read from file.  Files

containing commands may be created, allowing users to build their own commands.

 In this manner, users may tailor UNIX to their

individual requirements and style.

37

The Shell

 Standard Shell features:  Create an environment that meets your needs  Write shell scripts  Define command aliases  Manipulate the command history  Edit the command line  Some shells provide more facilities than others

38

slide-20
SLIDE 20

10/26/2009 20

The Shell

 There are several shells available for

Unix;

 You can use any one of these shells if

they are available on your system.

 You can switch between the different

shells once you have found out if they are available.

 Bourne shell (sh).  C shell (csh).  TC shell (tcsh).  Korn shell (ksh).  Bourne Again SHell (bash).

39

Operating Environment

 What is common to (most) installations

  • f OS

 OS kernel  System libraries  Common functionality for applications  One or more shells for user interaction  Utility software, for easy access to OS

services

slide-21
SLIDE 21

10/26/2009 21

The Main Features of UNIX

The features:

○ Multitasking capability, ○ Multi-user capability, ○ Portability ○ Security

 Most computers hosting WWW sites use UNIX (or

Linux) as their operating system

 WHY?

slide-22
SLIDE 22

10/26/2009 22

Reasons for its Popularity

 Only a very small amount of code in UNIX is

written in assembly language, making it easier for a computer vendor to get UNIX running on their system.

 The user benefit is that UNIX runs on a wide

variety of computer systems.

 The application program interface allows many

different types of applications to be easily implemented under UNIX without writing assembly language.

 These applications are relatively portable across

multiple vendor hardware platforms.

Reasons for its Popularity

 Third party software vendors can save

costs by supporting a single UNIX version of their software rather than four completely different vendor specific versions requiring four times the maintenance.

 Vendor-independent networking allows

users to easily network multiple systems from many different vendors.

slide-23
SLIDE 23

10/26/2009 23

Free Operating Systems

 Linux (including Red Hat Official Linux,

though that is a borderline case) and FreeBSD are free operating systems.

 They are often available for the cost of the

media ($2 to $5),

 The source code is available, often included

with the main distribution;

 There are few limits to redistributing the

system.

slide-24
SLIDE 24

10/26/2009 24

Linux

 Monolithic kernel, Unix-like  System libraries, e.g. /lib/  Shells: POSIX shells (e.g. bash) and

desktop environments (e.g. GNOME)

 System tools: GNU

The Linux Operating System

 As UNIX spread, many people wanted to adapt it for their

  • wn needs. In 1987 Professor Andrew S. Tanenbaum

invented Minix, an open-source OS that cloned UNIX.

 A young computer student in Finland named Linus Torvalds

became intrigued by the possibilities of MINIX

 In 1991, he posted a note in the MINIX newsgroup that he

had started work on a free operating system and asked his fellow programmers to help

 Over the next few years, developers for this new OS, dubbed

Linux (a mix of Linus and UNIX) swelled from the hundreds to the thousands.

slide-25
SLIDE 25

10/26/2009 25

Linux Operating System

 Characteristics

 Unix like  Open source (software that can be freely shared with no

  • ne person owning the code)

 requires less system resources to operate smoothly  in its native form, Linux has a command line

interface

 xWindows interface

The fact that Linux is being constantly updated and refined with the latest technologies ensures that it is reliable and secure

Reasons for its Popularity

 Linux is Network-friendly

 more networks set up in homes as costs for basic

computer hardware and networking equipment continue to fall.

 Linux is capable of acting as client and/or server to any of

the popular operating systems in use today  Linux is Multi-user

Built on the Unix design philosophy  Linux is Open

 Gives the ability to write kernel extensions and

drivers as needed  Linux is Reliable and Backwards-Compatible  Linux is "Free"

slide-26
SLIDE 26

10/26/2009 26

OS X

 Hybrid kernel (XNU), Unix varient  Core OS is Darwin, based on BSD  System libraries: /usr/lib/  Shells: POSIX shells, e.g. Bash  Desktop GUI (Aqua, Finder) built on top of OS

slide-27
SLIDE 27

10/26/2009 27

OS X for Mac

 The kernel for the OS X, was created in conjunction with

Apple's own engineers and computer scientists from Carnegie-Mellon and the University of California at Berkley.

 Apple has decided to embrace aspects of open source code

creation (While Microsoft is well known for maintaining an airtight lid on its Windows source code, ).

 Benefits:  encourage developers to submit modifications and

enhancements.

 programmers will be able to customise Mac OS X to meet their

specific needs.

 whole host of Macintosh products from Apple and third parties

that incorporate its exciting new technologies,

 new networking standards lets you automatically create a

network of applications, printers and other peripheral devices — without having to manually configure drivers or settings.

slide-28
SLIDE 28

10/26/2009 28

IBM OS/2 and OS/2 WARP

 OS/2 was developed by Microsoft and IBM, but

was later abandoned by Microsoft when it developed its own Windows operating system

 The "revolutionary" version was OS/2 warp 3,

produced in 1994

 Although it often has been declared extinct, OS/2

is still used among financial institutions and also has a small but enthusiastic group of desktop users.

More Recent Development in OS

 Parallel Operating Systems.  Distributed Operating Systems.  Clustered Operating Systems.  Real time Operating Systems.  Embedded Operating Systems.

slide-29
SLIDE 29

10/26/2009 29

OS Components Operating Systems

 Multiuser: several users on same OS  Multitasking: each running several

programs

 But a processor can only do one thing at a

time!

 Multiprogramming: allocates time slices

  • f a single processor to task

 Load balancing: allocates tasks among

multiple processors

slide-30
SLIDE 30

10/26/2009 30

Computer Platforms War

 PC (most of the market share)

○ competitive open mass market, drives price down ○ varying quality ○ lower cost ○ speedy software developments and high

availability

 Apple Macintosh (small part of the market share)

○ strict licensing/approval of third party products ○ higher cost ○ can be higher quality ○ specialist applications - example: audio, graphics

CPU

 I.E. Central Processing Unit  The ―brain‖ of the computer. All incoming events

and commands are interpreted here. Instructions

  • r calculations are carried out and the results of

these are output.

 This is what happens when you type something and it

subsequently appears on the screen.  Each processor in the CPU is measured by how

fast it oscillates (spins).

 If a processor has a speed of 500 million instructions per

second (500 million oscillations), its speed is 500MHz

 Examples of processors: Pentium and PowerPC

slide-31
SLIDE 31

10/26/2009 31

CPU Protection

 Sharing system resources requires

  • perating system to ensure that an

incorrect program cannot cause other programs to execute incorrectly.

 Provide hardware support to differentiate

between at least two modes of operations.

 User mode – execution done on behalf of a

user.

 Monitor mode (also kernel mode or system

mode) – execution done on behalf of operating system.

CPU Protection (cont)

 Mode bit added to computer hardware to

indicate the current mode: kernel (0) or user (1).

 When an interrupt or fault occurs

hardware switches to kernel mode.

Privileged instructions can be issued only in monitor mode.

kernel user Interrupt/fault set user mode

slide-32
SLIDE 32

10/26/2009 32

Memory Structure

 Typical memory hierarchy  numbers shown are rough approximations

Memory Protection

One base-limit pair and two base-limit pairs

slide-33
SLIDE 33

10/26/2009 33

I/O Devices

 I/O devices and the CPU can execute

either synchronously or asynchronously.

 Each device controller is in charge of a

particular device type.

 Each device controller has a local buffer.  CPU moves data from/to main memory

to/from local buffers.

 I/O is from the device to local buffer of

controller.

 Device controller informs CPU that it has

finished its operation by causing an interrupt.

I/O Devices Protection

 All I/O instructions are privileged

instructions.

 Must ensure that a user program could

never gain control of the computer in monitor mode (I.e., a user program that, as part of its execution, stores a new address in the interrupt vector).

slide-34
SLIDE 34

10/26/2009 34

OS Interfaces (Shell, API)

 Command interpreter: Interface between

OS and your fingers (or mouth…or toes!)

 Commands to manipulate files, run and kill

programs, access remote machines, change protections on files, etc.

 Some OS’s have ―built-in‖ command

interfaces, some allow an interface to be ―plugged in‖

 Unix: ―shell‖ (csh, tcsh, bash, ash, zsh,

…)

System calls - Programmer Interface

 System calls are the programmer’s

interface to the operating system

 In modern systems, generally available

from a high-level language such as C

 Examples: fopen(), ioctl() (see MOS Fig

1.18 for more systems calls)

 Previously: Most of OS was written in

assembly and system calls were made from assembly language

slide-35
SLIDE 35

10/26/2009 35

OS Structure…Or Not?

 Simplest system structure: little or none  Example: MS-DOS  Written to squeeze the most out of

limited hardware

 Small, some structure, but programmer

is free to go around whatever structure is present anyway

Monolithic kernel vs. Micro-kernel

 Monolithic approach:  OS provides:

○ File system, Scheduling, Device management,

and etc.  Components are separated by ―discipline‖ and

hacking requires care.

 For example, the traditional Unix has two

―layers.‖ - Systems programs, user programs.

 Micro-kernel approach:  Make kernel very small (provides only a limited

amount of the total OS functionality, like inter- process communication & basic H/W control).

 ―Plug in‖ virtual memory system, file system, etc.  Gives encapsulation w/o strict layering.

slide-36
SLIDE 36

10/26/2009 36

Virtual Machines

 Virtual machine: fancy software which

exports an interface that looks like a particular type of ―machine‖

 Can create illusions of multiple computer

systems, which can be like the physical hardware or completely different!

 Sometimes a VM environment actually

produces a virtual machine that's faster than the real thing…on the same hardware!

 Example: VDM's under OS/2 (virtual dos

machines)

 How can this be?

The Java Virtual Machine

 Java achieves (relative) platform-

independence through the JVM (Java Virtual Machine)

 JVM (java) is implemented for each

target platform

 Java compiler (javac) emits bytecode

(as *.class files) rather than architecture- specific machine code

 JVM interprets the bytecode

slide-37
SLIDE 37

10/26/2009 37

The Java Virtual Machine, Cont.

 Problem: Speed!  Java code typically executes more

slowly than ―equivalent‖ C or C++ code

 Solutions … (more like workaround!)  JIT (Just In Time) compiler, which compiles

the bytecode into native machine code immediately before execution

 AOT (Ahead of Time) compiler, which

compiles the bytecode into native machine code.

 Interesting issue: caching

Summary

 Stored program concept: program is data  Software & hardware (& firmware)  OS = Kernel + Shell  Kernels designed for different applications  Monolithic, microkernel and hybrid kernels  GUI & command-line shells  Reading: Brookshear §3