920 likes | 1.31k Vues
CSC 4320/6320 Operating Systems Lecture 2 Operating System Structures. Saurav Karmakar. Introduction. OS : Environment for application program So before designing the GOALS should be well defined. View of an OS : 1) Services 2) Interfaces 3) Components/Interconnections.
E N D
CSC 4320/6320Operating SystemsLecture 2Operating System Structures Saurav Karmakar
Introduction • OS : Environment for application program • So before designing the GOALS should be well defined. • View of an OS : 1) Services 2) Interfaces 3) Components/Interconnections
Chapter 2 Objectives • To describe the services an operating system provides to users, processes, and other systems • To discuss the various ways of structuring an operating system • To explain how operating systems are installed and customized and how they boot
Operating System Services • One set of operating-system services provides functions that are helpful to the user: • User interface - Almost all operating systems have a user interface (UI) • Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch • Program execution - Must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error) • I/O operations - A running program may require I/O, which may involve a file or an I/O device • File-system manipulation - Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.
Operating System Services (Cont) • Communications – Processes may exchange information, on the same computer or between computers over a network • Communications via -- shared memory or -- message passing • Error detection – OS needs to be constantly aware of possible errors • May occur in different sectors like the CPU and memory hardware, in I/O devices, in user program • For each type of error, OS should take the appropriate action to ensure correct and consistent computing • Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system
Operating System Services (Cont) • Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing • Resource allocation - Multiple users or multiple jobs running concurrently, resources must be allocated to each of them • Many types of resources • Accounting - To keep track of which users use how much and what kinds of computer resources • Protection and security – • Information stored in a multiuser or networked computer system. • control use of the information. • concurrent processes should not interfere with each other
User Operating System Interface - CLI Command Line Interface (CLI) or command interpreter allows direct command entry • Sometimes implemented in kernel, • sometimes by systems program • Sometimes multiple flavors implemented – shells • Primarily fetches a command from user and executes it • Sometimes commands built-in, sometimes just names of programs • If the latter, adding new features doesn’t require shell modification
User Operating System Interface - GUI • User-friendly desktop metaphor interface • Usually mouse, keyboard, and monitor • Icons represent files, programs, actions, etc • Invented at Xerox PARC in 1970s • Many systems now include both CLI and GUI interfaces • Microsoft Windows is GUI with CLI “command” shell • Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available • Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)
System Calls • Interface to the services provided by the OS • Typically written in a high-level language (C or C++) • Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use • Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM) • Why use APIs rather than system calls?
Example of System Calls • System call sequence to copy the contents of one file to another file
Example of Standard API • Consider the ReadFile() function in the • Win32 API—a function for reading from a file • A description of the parameters passed to ReadFile() • HANDLE file—the file to be read • LPVOID buffer—a buffer where the data will be read into and written from • DWORD bytesToRead—the number of bytes to be read into the buffer • LPDWORD bytesRead—the number of bytes read during the last read • LPOVERLAPPED ovl—indicates if overlapped I/O is being used
System Call Implementation • Typically, a number associated with each system call • System-call interface maintains a table indexed according to these numbers • The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values • The caller need know nothing about how the system call is implemented • Just needs to obey API and understand what OS will do as a result call • Most details of OS interface hidden from programmer by API • Managed by run-time support library (set of functions built into libraries included with compiler)
Standard C Library Example • C program invoking printf() library call, which calls write() system call
System Call Parameter Passing • Often, more information is required than simply identity of desired system call • Exact type and amount of information vary according to OS and call • Three general methods used to pass parameters to the OS • Simplest: pass the parameters in registers • In some cases, may be more parameters than registers • Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register • This approach taken by Linux and Solaris • Parameters placed, or pushed, onto the stackby the program and popped off the stack by the operating system • Block and stack methods do not limit the number or length of parameters being passed
Types of System Calls : Six Major Categories • Process control • File management • Device management • Information maintenance • Communications • Protection
Process Control • Process/Program halt (normally/abnormally) • Abnormal halt(Error trap/System Call). • Dump of memory taken, error message generated. • Debugger helps comes in this later. • Transfer gets back to invoking Command Interpreter(interactive System, GUI, Batch)
Process Control • If an executing job wants to load another - • What happens when control returns ? • Programs Calling each other mechanism • Concurrent program execution mechanism • Creating a new job requires to establish control over that properly too.
Single tasking system in execution :MS-DOS (a) At system startup (b) running a program
Types of System Calls (Contd.) • File management • Device management • Basically resource(physical/abstract) management
Types of System Calls : Six Major Categories • Information maintenance • Transfer of info between user program and OS • System call for debugging • Monitoring time profile of a program • Monitoring/Controlling Processes • Communications • Message Passing • Shared Memory • Protection • Controlling access to the resources • get/set permissions, allow/deny user.
1981 2006 Factor CPU MHz, Cycles/inst DRAM capacity Disk capacity Net bandwidth # addr bits #users/machine Price Moore’s Law Change Drives OS Change Typical academic computer 1981 vs 2006 10 3—10 3200x4 0.25—0.5 1,280 6—40 128KB 4GB 32,768 10MB 1TB 100,000 9600 b/s 1 Gb/s 110,000 16 32 2 10s • 1 0.1 $25,000 $4,000 0.2
Moore’s law effects • Nothing like this in any other area of business • Transportation in over 200 years: • 2 orders of magnitude from horseback @10mph to Concorde @1000mph • Computers do this every decade (at least until 2002)! • What does this mean for us? • Techniques have to vary over time to adapt to changing tradeoffs • I place a lot more emphasis on principles • The key concepts underlying computer systems • Less emphasis on facts that are likely to change over the next few years… • Let’s examine the way changes
Dawn of timeENIAC: (1945—1955) • “The machine designed by Drs. Eckert and Mauchly was a monstrosity. When it was finished, the ENIAC filled an entire room, weighed thirty tons, and consumed two hundred kilowatts of power.” • http://ei.cs.vt.edu/~history/ENIAC.Richey.HTML
History Phase 1 (1948—1970)Hardware Expensive, Humans Cheap • When computers cost millions of $’s, optimize for more efficient use of the hardware! • Lack of interaction between user and computer • User at console: one user at a time • Batch monitor: load program, run, print • Optimize to better use hardware • When user thinking at console, computer idleBAD! • Feed computer batches and make users wait • No protection: what if batch program has bug?
In 1946, when Hopper was released from active duty, she joined the Harvard Faculty at the Computation Laboratory where she continued her work on the Mark II and Mark III. Operators traced an error in the Mark II to a moth trapped in a relay, coining the term bug. This bug was carefully removed and taped to the log book September 9th 1945 [sic]. Stemming from the first bug, today we call errors or glitch's [sic] in a program a bug.
Core Memories (1950s & 60s) • Core Memory stored data as magnetization in iron rings • Iron “cores” woven into a 2-dimensional mesh of wires • Origin of the term “Dump Core” • Rumor that IBM consulted Life Saver company • See: http://www.columbia.edu/acis/history/core.html The first magnetic core memory, from the IBM 405 Alphabetical Accounting Machine.
History Phase 1½ (late 60s/early 70s) • Data channels, Interrupts: overlap I/O and compute • DMA – Direct Memory Access for I/O devices • I/O can be completed asynchronously • Multiprogramming: several programs run simultaneously • Small jobs not delayed by large jobs • More overlap between I/O and CPU • Need memory protection between programs and/or OS • Complexity gets out of hand: • Multics: announced in 1963, ran in 1969 • 1777 people “contributed to Multics” (30-40 core dev) • Turing award lecture from Fernando Corbató (key researcher): “On building systems that will fail” • OS 360: released with 1000 known bugs (APARs) • “Anomalous Program Activity Report” • OS finally becomes an important science: • How to deal with complexity??? • UNIX based on Multics, but vastly simplified
A Multics System (Circa 1976) • The 6180 at MIT IPC, skin doors open, circa 1976: • “We usually ran the machine with doors open so the operators could see the AQ register display, which gave you an idea of the machine load, and for convenient access to the EXECUTE button, which the operator would push to enter BOS if the machine crashed.” • http://www.multicians.org/multics-stories.html
Contrast: Seagate 1TB,164 GB/SQ in, 3½ in disk, 4 platters Early Disk History 1973: 1. 7 Mbit/sq. in 140 MBytes 1979: 7. 7 Mbit/sq. in 2,300 MBytes
Response time Users History Phase 2 (1970 – 1985)Hardware Cheaper, Humans Expensive • Computers available for tens of thousands of dollars instead of millions • OS Technology maturing/stabilizing • Interactive timesharing: • Use cheap terminals (~$1000) to let multiple users interact with the system at the same time • Sacrifice CPU time to get better response time • Users do debugging, editing, and email online • Problem: Thrashing • Performance very non-linear response with load • Thrashing caused by manyfactors including • Swapping, queueing
SRI 940 Utah PDP 10 IMPs UCSB IBM 360 UCLA Sigma 7 BBN team that implemented the interface message processor The ARPANet (1968-1970’s) • Paul Baran • RAND Corp, early 1960s • Communications networks that would survive a major enemy attack • ARPANet: Research vehicle for “Resource Sharing Computer Networks” • 2 September 1969: UCLA first node on the ARPANet • December 1969: 4 nodes connected by 56 kbps phone lines • 1971: First Email • 1970’s: <100 computers
First E-mail SPAM message: 1 May 1978 12:33 EDT 80-83: TCP/IP, DNS; ARPANET and MILNET split 85-86: NSF builds NSFNET as backbone, links 6 Supercomputer centers, 1.5 Mbps, 10,000 computers 87-90: link regional networks, NSI (NASA), ESNet (DOE), DARTnet, TWBNet (DARPA), 100,000 computers ARPANet SATNet PRNet TCP/IP NSFNet Deregulation & Commercialization ISP ASP AIP WWW 1965 1975 1985 1995 2005 ARPANet Evolves into Internet SATNet: Satelite network PRNet: Radio Network
What is a Communication Network?(End-system Centric View) • Network offers one basic service: move information • Bird, fire, messenger, truck, telegraph, telephone, Internet … • Another example, transportation service: move objects • Horse, train, truck, airplane ... • What distinguish different types of networks? • The services they provide • What distinguish the services? • Latency • Bandwidth • Loss rate • Number of end systems • Service interface (how to invoke the service?) • Others • Reliability, unicast vs. multicast, real-time...
What is a Communication Network?(Infrastructure Centric View) • Communication medium: electron, photon • Network components: • Links – carry bits from one place to another (or maybe multiple places): fiber, copper, satellite, … • Interfaces – attach devices to links • Switches/routers – interconnect links: electronic/optic, crossbar/Banyan • Hosts – communication endpoints: workstations, PDAs, cell phones, toasters • Protocols – rules governing communication between nodes • TCP/IP, ATM, MPLS, SONET, Ethernet, X.25 • Applications: Web browser, X Windows, FTP, ...
Network Components (Examples) Links Interfaces Switches/routers Ethernet card Large router Fibers Wireless card Coaxial Cable Telephone switch
History Phase 3 (1981— )Hardware Very Cheap, Humans Very Expensive • Computer costs $1K, Programmer costs $100K/year • If you can make someone 1% more efficient by giving them a computer, it’s worth it! • Use computers to make people more efficient • Personal computing: • Computers cheap, so give everyone a PC • Limited Hardware Resources Initially: • OS becomes a subroutine library • One application at a time (MSDOS, CP/M, …) • Eventually PCs become powerful: • OS regains all the complexity of a “big” OS • multiprogramming, memory protection, etc (NT,OS/2) • Question: As hardware gets cheaper does need for OS go away?
Xerox Star Single Level HAL/Protection Windows 3.1 No HAL/ Full Prot History Phase 3 (con’t)Graphical User Interfaces • CS160 All about GUIs • Xerox Star: 1981 • Originally a researchproject (Alto) • First “mice”, “windows” • Apple Lisa/Machintosh: 1984 • “Look and Feel” suit 1988 • Microsoft Windows: • Win 1.0 (1985) • Win 3.1 (1990) • Win 95 (1995) • Win NT (1993) • Win 2000 (2000) • Win XP (2001) • Win Vista (2007)
History Phase 4 (1988—): Distributed Systems • Networking (Local Area Networking) • Different machines share resources • Printers, File Servers, Web Servers • Client – Server Model • Services • Computing • File Storage
History Phase 4 (1988—): Internet • Developed by the research community • Based on open standard: Internet Protocol • Internet Engineering Task Force (IETF) • Technical basis for many other types of networks • Intranet: enterprise IP network • Services Provided by the Internet • Shared access to computing resources: telnet (1970’s) • Shared access to data/files: FTP, NFS, AFS (1980’s) • Communication medium over which people interact • email (1980’s), on-line chat rooms, instant messaging (1990’s) • audio, video (1990’s, early 00’s) • Medium for information dissemination • USENET (1980’s) • WWW (1990’s) • Audio, video (late 90’s, early 00’s) – replacing radio, TV? • File sharing (late 90’s, early 00’s)
Regional Nets + Backbone Regional Net Regional Net Regional Net Backbone Regional Net Regional Net Regional Net LAN LAN LAN LAN: Local Area Network