Presentation is loading. Please wait.

Presentation is loading. Please wait.

BS2911 Week 2 1 Networking and the Internet (2) l Last Week: »Why does Networking matter? »Some thoughts about e-Business »Hardware foundation – Computer.

Similar presentations


Presentation on theme: "BS2911 Week 2 1 Networking and the Internet (2) l Last Week: »Why does Networking matter? »Some thoughts about e-Business »Hardware foundation – Computer."— Presentation transcript:

1 BS2911 Week 2 1 Networking and the Internet (2) l Last Week: »Why does Networking matter? »Some thoughts about e-Business »Hardware foundation – Computer architecture l Week 2 Focus »Computer architecture – working through operations »Software – Operating Systems, File storage »Operating system foundations – Interrupts, concurrency and multi-programming –Scheduling and Dispatching –Time-sharing and Online systems »Graphical Operating Systems, including Windows Useful text-book: Coope, S et al (2002) Computer Systems McGraw Hill

2 BS2911 Week 2 2 Computer Architecture Processor Memory Disk Storage Other long-term Storage l Processor executes instructions from memory, l and works on data in memory l Other data flows through the bus 1234567890-= QWERTYUIOP[]# ASDFGHJKL;’ ZXCVBNM,./ Input (Data) Output (Information) Bus

3 BS2911 Week 2 3 Architecture – Notes l The machines you’re working with have at least 1GB of memory. That is, there are more than a billion separately-addressable units of memory, each consisting of eight electronic switches. These groups of eight binary digits (bits) are called “bytes” and can hold 2 8 values (0 up to 255). Because the whole machine works in binary, things usually come in powers of two – a “K” is 2 10 or 1024, and an M is 2 20 or 1,048,576. Inconsistently, “G” usually means 10 9 for disk drives, and 2 30 for memory and for processor speeds. l The memory has a cycle-time of under 30nanoseconds, which is slower than the processor, but faster than the bus. That’s why the processor talks to memory without going through the bus. It’s also why modern computers use a local bus called PCI to connect to the fastest devices, and the some have an even faster connection, AGP, to the display. PCI runs faster than the old ISA (Industry standard architecture) bus I’ve illustrated here. l Many machines have a diskette drive called A: and a fixed disk drive called C: You can have more than one of each, so you may have a B: drive (diskette) and a D: drive (fixed). Other devices, such as DVD-ROM, usually have the next spare letter after the last disk. l Windows 95/98, NT, 2000, XP, Vista and W7 allow you to connect computers together in a network, and to share disks. These can be linked as if they were physically on the machine, and then usually have a letter after the DVD-ROM. You will be familiar with keeping all your personal data on a network disk – that’s where your “My Documents” is. l Because data is often more valuable than the computer it’s on, and hard disks have been known to fail, back-up devices are needed. Tape gives the best combination of speed, convenience and cheapness of medium, but DVDs are much more affordable for home.

4 BS2911 Week 2 4 Computer Processor & Machine code Arithmetic and Logic Unit Clock Instruction Control Unit (starts at 310) Instruction Register Memory 31011600 31412602 318512 31A21604 1 = Load 2 = Store 3 = Add 4 = Subtract 5 = Multiply Memory 6004 6026 6044660 6064608 6084660 60A-14 Registers 1 2 Central Processor Unit...

5 BS2911 Week 2 5 Machine code example To simplify this example, I’ve chosen a processor that addresses memory by the word (of 32 bits). This means there’s room at a single memory address for an instruction code, register-number and an address, or for a full-word number. Such machines were common before the IBM 360, but most modern machines actually address each byte. The diagram shows two areas of memory, one containing instructions, and the other data. There’s no need for this separation, but it makes things easier to understand. The first area contains program, and is laid out to show instruction code, register affected, and finally the address of memory accessed (or second register). That is: Instruction CodeMeaning 1 r sLoad register r from memory location s 2 r sStore register r into location s 3 r1 r2Add r1 to r2 and put result in r1 4 r1 r2Subtract r2 from r1 and put result in r1 5 r1 r2Multiply r1 by r2 and put result in r1 We’ll work through the program, writing in the changes that occur during execution Homework: Please study the paper at the end of the hand-out, to understand the (slightly) more realistic byte-oriented computer described there. If you can’t do that, try working through the example here, noting the value of each register and each word in the 600 range of memory at the end of each instruction (as read from memory locations 310-31A)

6 BS2911 Week 2 6 Operating Systems How we control this hardware

7 BS2911 Week 2 7 Operating Systems l Though the processor is simple and serial, we want to do more complex things, often several at once l An operating system is a program that provides the building blocks of complex systems »Some simply encapsulate function to save every application from having to include a copy »Others handle specific hardware, presenting a generic interface that hides behaviour unique to that hardware »Sometimes the interface is so generic that it has little to do with the hardware – file structures are the best example l Modern operating systems make it look as if the computer is doing several things at the same time »Our operating system is Windows XP

8 BS2911 Week 2 8 Operating Systems – Notes l The original goal of operating systems was to save programmers from having to do the repetitive task of writing machine-code to do common operations such as reading cards, driving printers, or typing a message to the operator. This was achieved by producing a series of routines (or macros) to do these actions, and packaging them with the computer. So you’d have routines to compute a square root, rewind a tape, punch a card, and all the other common activities. This is what we’d now call “encapsulation of function.” You get it right once, put an envelope round it, and forget what’s inside. Through the 60s, operating systems encapsulated ever higher levels of function. For example, OS/360 abstracted the process of printing, so that the program’s print commands actually wrote data to a spool file, and only when the program closed its printer did the operating system actually start moving the records from disk to the physical printer. OS/360’s descendants still dominate the world of enterprise computing (MVS, OS/390, now called z/OS) l Under DOS and its descendants (OS/2 and Windows), disk I/O is done by reading and writing named files, which are logically linear collections of records. The operating system takes care of mapping from the file identifier to the place on disk where the records are physically stored, and glues together a non-contiguous string of physical blocks (allocation units) to present logical records to the program. The operating system delivers the data via buffers in memory. l Because the application doesn’t need to know the structure of the disk, you can run programs with a physical disk replaced by a CD or a memory key. l A key service of all operating systems is to make use of a single processor resource to doing several things concurrently. We’ll cover that in some detail in this module.

9 BS2911 Week 2 9 Concurrent Operations l To give the appearance of doing several things at once: »OS must stay ready to accept work: –keystrokes, mouse clicks, signals from modem, printer ready to receive another buffer of data –These can interrupt a computation already being run »It then does a bit of the required work, »then goes back to an interrupted task, and so on. l We say the machine is doing things “concurrently” – they’re not simultaneous, but they look it! l The key is switching the CPU between logical processes »In theory, you could go round “polling” – high overhead »In practice, concurrency depends on hardware interrupts

10 BS2911 Week 2 10 Essentials of an operating system l Controls the hardware »Lets applications be less hardware-specific by abstracting operations (who cares how big a track is!) »Reduces havoc that can be done by rogue programs by restricting use of risky instructions (such as those giving direct access to hardware) »Allows processes to update files with integrity l Encapsulates commonly-used functions l Manages resources, including storage l Supports concurrent operations l Success judged by performance, in terms of Availability, Reliability, Response-time, Throughput

11 BS2911 Week 2 11 In the beginning... l 21 June 1948: First stored-program computer (Manchester University “Baby”) ran its first program »Program keyed directly into memory »Results displayed as dots on a CRT »When program finished, it stopped »Next machines used tape or card for I/O l Monitors developed in 1950s »encapsulate standard functions (for example, Input/Output) »automate running of programs one after another »still one program at a time »then added SPOOLING to overlap input and output Too much investment to let it sit around waiting for humans to press buttons

12 BS2911 Week 2 12 The Early Days of Computing l The MU “Baby” was a kind of “0th generation” computer to prove that a stored program computer could be built. The idea of writing machine-code using a binary keyboard made of Spitfire radio buttons was not seen as a practical option for real computers! It was the prototype of first- generation machines like the Ferranti Mark I, which had a real keyboard and paper-tape reader, allowing you to prepare programs off-line. Given the high cost of building and running a machine containing thousands of valves, you didn’t want it to stand idle waiting for humans to input work. l Early computers were dedicated to a single user, who supplied instructions via a typewriter (slowly) or punched cards (faster). In the UK, paper tape was more usual than cards, but the principle was the same – do the typing off-line. l With the second-generation of machines, using transistors instead of valves, processing was much faster, but the electro-mechanical devices like readers and printers were faster by a smaller factor. So it made sense not to hold up the processor waiting for these devices to finish, and SPOOLing was introduced. This was performed under the control of a Monitor. Programs wrote their output to a SPOOL file on disk, and the monitor transferred data from the disk to printer or punch at times, “stealing” processing time from the program being run. l This meant that each program took a little longer than it would have done for its processing alone, but the system could start the next job without waiting to complete output from the previous one. This increased throughput, though an individual user might have to wait a bit longer, since printing didn’t begin until the SPOOL file was closed at the end of the job. l Input of jobs and data was handled in the same way, so the monitor could switch to the next job in sequence without waiting for human action. l These monitors introduced the concept of “concurrent processing” – appearing to do two things at once by switching the processor from one task to another.

13 BS2911 Week 2 13 True Operating Systems l Introduced with Ferranti Atlas and IBM System/360 l Applied concurrency to user work as well as to SPOOL »Potential to run complementary jobs alongside each other l OS became a resource manager »Sharing processor resource between jobs »Providing separate memory for use by each job »Controlling allocation of tapes and other hardware »Scheduling jobs to fit resources available l Used interrupts to switch control between processes »Need to be sure we understand how they work l Foundation for on-line systems with terminals

14 BS2911 Week 2 14 Interrupts l The hardware feature called an interrupt was key to most operating systems developed from the 60s onwards. An interrupt swaps the current instruction counter value for the address of an interrupt handler, preserving the old value at an address defined for each class of interrupt. This avoids the need to “poll” to see if (say) the printer is ready for another line from SPOOL, and makes it efficient to switch between activities. l So the printer driver can write a line to the printer interface, then enter a wait state until the printer interrupts to show that it’s finished writing that line and is ready for another. Under the covers, “waiting on an event” simply means that the operating system has built a control block in memory, containing information to let it revive the waiting task when a particular interrupt event arises – for example, when the printer interface returns a device-end interrupt. l The Operating System became the real job running on the computer. User work was divided into “tasks” (what we’d now call processes), which were attached by the Operating System to be given resources when they were available. At the end of interrupt handling, instead of returning to the instruction that was interrupted, control would be returned to the operating system, which would allocate the processor resource to the most appropriate task. So you could run several jobs at once, possibly matching a compute-intensive analysis with a data-intensive billing job. l This concept of task-switching can also be used at a lower level. For example, if you have a business system with a thousand users sitting at terminals, you could have a task running for each terminal (plus a few more to control the whole system). Then each time my task writes to the terminal, it could go into a wait state, waiting for an event that shows the terminal has sent some new data (usually, this won’t happen until the user has read the last output, thought about it, typed in a response, and hit the Enter key). Thus the development of efficient online systems was dependent on the concept of tasks and events.

15 BS2911 Week 2 15 On-line Computing l Terminal attached to mainframe computer l Operating system “time-shared” processor among users l Developed initially with slow lines and typewriter-like terminals or teleprinters, which sent a character at a time l It was expensive to read every keystroke »so switched to using “Block mode”: »User types into terminal buffer, presses Enter to transmit l Most transaction processing is done that way, even today l Weaknesses of mainframe + terminal are »poor bandwidth: can’t track mouse, write graphics »can’t take shortcuts based on every keystroke

16 BS2911 Week 2 16 Working interactively l Early computers were dedicated to a single user, who supplied instructions via a typewriter (slowly) or punched cards (faster). As Operating Systems developed, they used the typewriter as Operator console; the control point from which programs were started and stopped. This console was the model for the time-sharing systems of the late 60s: implicitly as in Unix, or explicitly as in IBM’s CP/67, which shared out system resources into Virtual Machines, with console, disks, card-punches etc. The Control Program created virtual machines that could run any program that would run on a hardware System/360, and the other component was a simple monitor to support a single user on that virtual machine. l Initially, each virtual console was a typewriter terminal with a direct wire to the mainframe, but this gets expensive, so techniques developed to attach many terminals down a single line. But it’s costly to transmit every keystroke with controls to indicate which device it’s from, and to have the processor waiting to unpick them. So terminals were provided with buffers for the user to type into, and data was sent in a block when s/he pressed the Enter key. This mode of operation took off with the IBM 3270 terminal, which held 24 lines of 80 characters. l Although PC screens look similar, the connection from keyboard to processor is more direct and very fast, so programs quickly took advantage of ability to see every keystroke (again!). The high bandwidth to the screen was exploited for graphics and typographical fonts, and for WIMPS interfaces such as MacOS, GEM, OS/2 and Windows. l PCs remain inferior to mainframes for handling shared data, and have a high cost of maintenance. How do you keep all your PC software up to data and compatible?

17 BS2911 Week 2 17 Basic Concepts Covered So Far l Faking concurrency »multiprogramming: appearing to do several things at once »processes and threads »For multiple users – or one user with several balls in the air l Interrupts l There’s more to come on: »I/O buffering »Spooling (offline, online) »Multiprocessing –Using multiple processors to get more power –symmetrical, clustering or master-slave

18 BS2911 Week 2 18 Summary of Concepts l This race through the history of Operating systems has introduced most of the basic concepts on which modern computer systems rest. l The concept of concurrency depends on switching the attention of a processor between many different tasks, such that each of them makes enough progress to satisfy its human user, or to handle real-world event sufficiently quickly (if you have a computer controlling the flying surfaces of your Airbus, you can’t afford to wait too long before responding to a change!). The computer in your cell-phone is capable of detecting a call, or switching cells at the same time as you are entering a number into memory or writing a text message. l In most systems, there are two levels of tasks, called processes and threads. The higher-level task is a process, and is associated with a complete system state (address-space, control blocks, processor state). It’s quite time-consuming to restore this whole state, so processes are often divided into threads. These lower-level tasks can share characteristics, such as the process address-space, so it’s not necessary to reload this when switching threads. We’ll see later how high-performance transaction systems depend on thread-based despatching. l When we need more power than a processor can provide, the obvious solution is to add more processors. Sometimes it’s on a very low level, with separate “engines” inside the processor for different functions such as instruction decoding, floating point, and graphics. Where an instruction passes through several of these, we say the processor is “pipelined.” Where there’s division of labour between different engines, we call them “coprocessors.”

19 BS2911 Week 2 19 What Operating Systems Do OS/360 and Batch Scheduling How Online Computing is different

20 BS2911 Week 2 20 OS/360 l “Betting the Business” for IBM in late 1960s l Environment: »Batch processing »Real memory only (Ferranti Atlas had paging, but the idea hadn’t yet crossed the Atlantic) »Physical cards used for job entry »Line-printers used for output (up to 1000 lines/min) »Tapes and disks expensive but heavily used l Concepts »Job Control Language (JCL) to describe each job »Each program ran in a Job Step

21 BS2911 Week 2 21 Structure of a Job l Must run steps in sequence l Don’t run step if previous one failed l Must have input available at start of step l Need somewhere to write results l Usually generate spool output l Normally expects the Program run in each step to be on disk Whole Job Step 1, e.g. compile program Step 2, e.g. link-edit program Step 3, e.g. run program Step 4, e.g. sort output Step 5, e.g. run utility on result Needs card input + workfile Needs object deck + workfile Needs module + input data Needs output data Needs sort output + target file //ERICJOB //COMPEXECPGM=PLIOPT //SYSINDD* //SYSPRINTDD* //SYSOUTDDDSN=“ERIC.PLI.OBJ” //LINKEXECPGM=LKEDIT /* and so on

22 BS2911 Week 2 22 Scheduling Jobs l Back in the days of monitors, scheduling was easy »When a job finishes, load the next one and run it »If I/O is spooled, next one will be loaded from spool file that contains images of cards read in earlier.. »..and CPU time needs to be shared between the running job and spool I/O (which uses predictably little CPU) l Gets harder when more than one real job can run »Have to match resource requirements with availability »Need to be concerned with sequence of jobs »Optimization needs awareness of job type (processor-heavy, I/O heavy, etc.) »Specified with complex Job Control Language

23 BS2911 Week 2 23 OS/360 Batch Scheduling l Memory was critical resource (>$1000 per kilobyte) l Divided into partitions or regions, each with a job initiator l OS reads each job in and places it on a (prioritized) queue l When job completes in region, initiator looks on queue for more work »Must fit in available memory »Necessary resources must be available »Otherwise try continue looking down queue Print spool Operating System Card spool Job 1 Job 2 Job 3Job 4 Job 5 Job initiators Job queue Wasted fragment of storage memory

24 BS2911 Week 2 24 Batch Scheduling Problems l Storage »With fixed-size partitions, you can have long queues for a big partition while one or more small ones are free »With variable-sizes (“regions”), you get fragmentation »Various steps may have different space requirements l Resource allocation »Need to collect together all resources needed by a step: such as files and dedicated hardware »Can still waste run time (e.g. if you get a tape drive but haven’t mounted the right tape on it) »Addressed by extensions to Job Control Language (even more chances to make mistakes with it!)

25 BS2911 Week 2 25 Risks of Deadlock OS/360 enforced pre-allocation to avoid deadlock l Consider two jobs, A & B l Job A »is holding tape drive 1 »can’t complete until it can update file X.Y.Z l Job B »is writing file X.Y.Z »can’t close the file until it’s written a log to tape »BUT there are no tape drives available l Therefore both jobs will stall, tying up both regions l But you can’t pre-allocate with on-line users

26 BS2911 Week 2 26 Scheduling Today l We’re not usually concerned with resources on a home PC »Schedule an anti-virus upgrade and it’ll run quickly (though running the virus checker might be much slower) l We may be concerned about sequence »Better to be sure the upgrade is complete before scanning l In business systems: »Duration can be longer (that’s why ITS constrains disk space; otherwise the back-ups would take too long) »Sequence can be critical – don’t pay out before taking in »Every transaction must run once and once only

27 BS2911 Week 2 27 Scheduling and Dispatching l Once we’ve scheduled jobs to start, we have to divide machine cycles between the concurrent processes »With a small degree of multiprogramming (few regions), that can be fairly simple »Whenever a region waits, we dispatch another one »Dispatcher is like a micro-level scheduler »Often have different dispatch and initiator priorities l Storage limitations addressed with Virtual Memory »Allowed increase in number of initiators »Increasing degree of multiprogramming.. ».. and need for more complex dispatching – there’s no point in dispatching a process without (real) memory

28 BS2911 Week 2 28 Online Systems l Expands scale of allocation and dispatching problems l “Jobs” become very long-running »so we can’t pre-assign all resources and hold until job end »Total number of jobs grows greatly »Jobs need to sleep when user isn’t interacting »Each interaction is like a mini job step l Two basic approaches to managing this »Treat each user as a process and tune the dispatcher »Unix, VM/370, MVS/TSO and VMS work this way »Treat each user as a thread on a “timesharing” process »CICS and IMS work this way »High-performance web servers too

29 BS2911 Week 2 29 Time-sharing l Consider a system with 100 on-line users »Average think time 10 seconds (so overall arrival rate is 10 interactions per second) »Average CPU demand of 50msec per interaction »Therefore load should be 50% plus overhead »If load is homogeneous, “round-robin” dispatching is OK l But what if a few users need 1 sec & the rest 10 msec? »Queue will build up if the long task is allowed to complete »OK, let’s preempt task on expiry of a time-slice; suspend task (take the CPU away) if it takes too long, and make it wait until next time round

30 BS2911 Week 2 30 Life Cycle of an Interaction Task Created User hits ENTER Terminated Executable Task Finishes Running On Ready Queue Blocked Dispatched Requeued on Event Time expires Enters WAIT Task runs until interrupted for some reason

31 BS2911 Week 2 31 Dispatching Tasks l Let’s assume a Ready Queue of tasks waiting to run »OS adds tasks to queue according to a priority pattern (cheapest is FIFO*, but we may want to improve on that) »Dispatch the task at the head of the queue »When it gives up control, dispatch new head of queue »May want to maintain queue of blocked tasks too l What if task doesn’t give up control? »Need to interrupt it at end of time slice to let others run (Windows 3.x didn’t do this except for DOS tasks) »Can return it directly to Ready Queue (with risk that it’ll consume too much CPU time) »Maybe we should favour short interactions over long * First In First Out

32 BS2911 Week 2 32 Graphical Operating Systems Development of Windows

33 BS2911 Week 2 33 Graphical Operating Systems l WIMP concepts »Windows, Icons, Menus, Pointer »invented late 70s at Xerox Palo Alto Research Center l First marketed in Lisa machine – very expensive »Later in Xerox “Daisy” – still too costly to succeed l Apple made success of the idea in Macintosh – 1984 »Massive advertising campaign »Succeeded first with designers and Desk Top Publishing l IBM & Microsoft followed with 16-bit OS/2 V.1 (1987) »Full WIMP approach in 1988 »IBM Went it alone for OS/2 V2 – incompatible interface

34 BS2911 Week 2 34 Early Flavours of Windows l Windows 1 and 2 »Never really made it – Lisa ideas done less well than Mac l OS/2 Version 1 (Microsoft/IBM collaboration) l Windows 386 »Exploited 80386 virtual machine code; Win2 interface l Windows 3.0 (1990) – The breakthrough »Picked up OS/2 V1 user interface, with simpler API »Added Windows 386 process mgt (multiple DOS boxes) »Still no pre-emption of ill-behaved Windows processes l Windows 3.1 »Enhanced Win3.0 without major architecture changes »Added some new GUI controls

35 BS2911 Week 2 35 Flavours of Windows since 1993 l Windows for Workgroups (3.1 and 3.11) »Added networking capabilities »Introduced (some) 32-bit code, such as file I/O »You could bolt-on IP network support – free but not trivial l Windows 95 – New user interface »Integrated IP networking »Much more 32-bit code »Long file-names (and file-types, unlike OS/2) »Still not fully pre-emptive multitasking, but improved capability to detect and abort ill-behaved processes l Windows 98 – Minor changes from W95 »Adds Internet-like interface to Windows 95 »Meant to be “last of the line of Windows 3.x successors”

36 BS2911 Week 2 36 Windows NT l NT V3.x »Microsoft’s OS/2 successor, with full Windows GUI »Kernel based on experiences with VMS (at Digital) »Data permissions RACF style, by user and group »32-bit, with some limitations on use of 16-bit applications l NT V4.0 »Enhanced from NT V3.51 »Added Windows 95 user interface »Improved tolerance of 16-bit applications… »…providing they don’t try to access the hardware directly »Full pre-emptive multitasking – Windows processes get time-sliced, so ill-behaved ones can’t hog the processor

37 BS2911 Week 2 37 Current Windows Flavours l Windows 2000 – Intended to unify NT and 9x families »To avoid duplicate development effort »Replaced NT for professionals and large & small Servers »But Domestic version didn’t run all W98 software, so… l Millennium Edition (of Windows 98) »Stopgap because 98/NT integration wasn’t complete l Windows XP – finally did unite NT and 9x families »Came in versions for different purposes –XP Home edition, –Professional edition for corporate clients –Servers l Similar approach with Windows Vista (2007) and W7 Increasing price

38 BS2911 Week 2 38 Summary of Week 2 l Computer does simple things, in sequence »Instruction counter contains address of next instruction to run l Operating systems package these into useful facilities »Including ability to run programs concurrently l Processor is a resource that the Operating System uses »OS treats each program as a task »Gives it a bit of time on the processor »Then passes the processor to another task l OS gets control back through interrupts »Voluntary (supervisor call by user program) »External (such as disk I/O completion, timer interrupt)

39 BS2911 Week 2 39 Checkpoint Questions l Describe differences between B2C & B2B e-Commerce »1. »2. l What are the main functions of an Operating System? »1.2. »3.4. l What does the “Instruction Counter” point to?


Download ppt "BS2911 Week 2 1 Networking and the Internet (2) l Last Week: »Why does Networking matter? »Some thoughts about e-Business »Hardware foundation – Computer."

Similar presentations


Ads by Google