1 / 25

Networking and the Internet (5)

Networking and the Internet (5). Last Week: Network Architecture – packet switching Memory – Virtual and Real (Coope, chapter 4) HTML Tables and Practical work Week 5 Focus Compilers and linkers; interpreters (Willis, ch.7, sect 7.7) Interrupts and status; processor modes (Coope, chapter 9)

lacy
Download Presentation

Networking and the Internet (5)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Networking and the Internet (5) • Last Week: • Network Architecture – packet switching • Memory – Virtual and Real (Coope, chapter 4) • HTML Tables and Practical work • Week 5 Focus • Compilers and linkers; interpreters (Willis, ch.7, sect 7.7) • Interrupts and status; processor modes (Coope, chapter 9) • Module assignment • Frames – HTML to display multiple pages at once • HTML Practical

  2. In the beginning machine code(1948 to around 1950) Then Assemblers developed translate 1:1 to machine code Processor-dependent As complex as the processor (at least) Still in use today High-level compiled languages(from 1956) Processor-independent FORTRAN, Cobol, ALGOL, Pascal, C, PL/I Interpreted languages (from 1960s) Translated as program runs Basic, APL, REXX Report Generators (from 1970) Also called 4GL: 4th generation Based on definitions of input and output ......not procedures to transform Object-oriented Aims to model real world, defining methods for objects Visual Basic, C++, Java Programming Languages

  3. Producing Machine Code • What runs in the CPU is a series of numeric codes in memory – machine code • We’ve already seen those (BS2911w2.doc) • Problem is that humans are lousy with numbers • So we represent them with mnemonics like LOAD & ADD • Also use symbols to represent data addressesDefinitions: A, B, C DS INT4 Executable code: LOAD A; ADD B; STORE C • Assemblers produce machine code in two passes: • First determines which symbols and labels existin this case, it has to reserve three words for integer data, perhaps A at 00 0F 0C, B at 00 0F 10 and C at 00 0F 14 • Second pass fills in the addresses for the symbols

  4. Let’s write a program to addC = A + B Assume the following codes: 01 is written as LOAD 02 written as STORE 03 written as ADD 04 written as SUB… and so on So we program as: LOAD A ADD B STORE C(more code would go in here)…A DS INT4B DS INT4C DS INT4 First pass, we translate codes and prepare data storage (1-byte code, 3-byte addresses) Let’s start from cell 00 0C 00C00 01 C01 needs AC04 03 C05 needs BC08 02 C09 needs C(assume more code up to… F0C holds AF10 holds BF14 holds C Now we can resolve the symbols to machine codeC00 01 00 0F 0CC04 03 00 0F 10C08 02 00 0F 14 The processor can run this Example of an Assembler

  5. High Level Languages • Writing assembler still needs you to think about how machine works • 1:1 correspondence of mnemonic to code • plus “macros” – mnemonics that produce several codes • Better if we can write in something closer to English • Machine independent • Calculations written like algebraic formulae: C:=A+B • Choices written as structures: IF xx THEN yy ELSE zz • Loops handled in structured way: WHILE xx DO … END • One formula generates many machine instructions • Process of converting to machine code is Compilation • Slow to compile, but MUCH faster to write

  6. Running a program • Compiling high-level language needs more than 2 passes • Declarations, internal subprogram calls, syntax… • Then compiler needs to do what the Assembler does • “Object code” produced still has unresolved references such as starting points of external subprograms • These must be resolved before pointing CPU at the code • In real life, machine code runs under OS control • Program calls built-in and OS subprograms • Location is determined by OS at run-time • So Assembler can’t produce absolute addresses • Most computers have hardware features to assist • OS sets a Base Register to hold the starting address, and compiled program contains offsets from that

  7. Dynamic Link Libraries Running the Compiled Program • Before running, machine code has to be loaded into memory • As object module is read, the loader does two things: • “relocates” the module by adjusting addresses to take account of starting point • makes a list of unresolved references – names used but not defined inside the module • It then tries to resolve references using entry-points in known modules (OS, function libraries, etc.) • where to look may be a defined in a LIBPATH • in Windows, main resolution is through DLLs • All this takes time, so we may try to do it once, creating a load module with a Linkage Editor or Builder

  8. Compile or Interpret? • Compilers typically generate efficient code, but: • Change cycle is long – Edit/Compile/Link/Load/Run • Each compilation takes time and resource • Source code isn’t usually available for run-time debugging • Wouldn’t it be nice to “compile on the fly”? • Interpreters do this, for example APL, REXX, Basic • Generally limited ability to look-ahead • Undeclared variables get “typed” by what goes into them • Each statement is read and converted to machine code when it’s needed • Some interpreters redo this every time a statement is run • Excellent diagnostics available – if code fails, source can be displayed with values of variables in use

  9. Instruction Control Unit(counter = C00) Registers 1 2 Instruction Register Memory F0C 4 F10 6 F14 4660 F18 4608 F1C 4660 F20 -14 Processing without Interruption Clock Arithmetic and Logic Unit Central Processor Unit 1 = Load 2 = Store 3 = Add 4 = Subtract 5 = Multiply Memory C00 1 1 F0C C04 1 2 F10 C08 3 1 2 C0C 2 1 F14 ….. …. Processing happens one instruction after another C00, C04… ...

  10. Interrupts • Interrupts are a hardware facility for controlling software • All current processors depend heavily on interrupts • Essentially, work by swapping the Instruction Counter • Interrupts can be caused by many things: • I/O hardware ready (device end after moving data) • External event (such as timer or keyboard) • Paging exception (DAT can’t give real address) • Program check (e.g. because instruction unknown) • this is a neat way to invoke software emulation of an instruction not present on this particular model of CPU • Supervisor call (e.g. task asks OS for a service) • Interrupts are the basis of much task switching, as well as detecting errors that the OS must deal with

  11. Interrupt handling • Let’s assume we have finished our time-slice, and the timer has just signalled the fact and interrupted us • Interrupt hardware will save current IC value in (say) loc 40 • Then set IC to the address given in (say) location 60 • CPU then executes interrupt handler code at this address • First it has to save state vector of interrupted task • registers, privilege level (e.g. supervisor state)… • then do what’s needed to service the interruptprobably jump into the scheduler to pick next ready task • IBM S/370 maintains state information in PSW • Hardware swaps whole Program Status Word, not just the instruction counter • Each interrupt class loads its own “new PSW”

  12. Processor modes • Clearly we could lose our return address if an interrupt handler is interrupted (by the same class of interrupt) • So we need to Mask against this class • and usually against lower-priority interrupts as well • This mask is another component of the S/370 PSW • defines one of the processor’s modes • Other processor modes (examples again for S/370) • Supervisor state: Needed to run privileged instructions • Allows OS to do things not permitted to applications • Certain instructions need current PSW in Supervisor state • If you’re in User state, you get a Program interrupt • Storage key: lets you protect your code and data from being overwritten by another task

  13. Finishing Survey of HTML Last week – Creating Tables Tables allow you to present tabular data without worrying about the size of the viewer’s window Dividing a window into Frames Frames let you present more than one WWW page at a time

  14. Netscape Frames • Typical Example of how HTML has grown • Netscape extended HTML to address a navigation issue • Other browsers climbed on to the bandwagon • HTML standards committee added the facility • Idea is that we can attach pages within logical frames inside our page • Gives common look and feel to site • Makes navigation information permanently available • Lets you include alien material in your website BUT: • Burns up valuable screen real-estate • Address bar always reflects the original frame-set

  15. Frames are a useful way to organize content of screen You can have a fixed bit, perhaps for navigation; and what the user does there can control what appears in another frame E.g. we might have choice of what appears in the RH pane Normal way to organize modern web-sites Details on the web at http:// sharkysoft.com/tutorials/frames/ Summary in your notes Basic structure is a page that defines how it is split into frames, hyperlinks to the resources that go into each frame Awkward shapes can be produced by binary chopping Each frame can be named You can control which named frame gets updated with next resource or even create a new browser window Best way forward is to try it Frames

  16. Learning about Frames • As usual, the best thing is to try it with a simple example • Download frames.zip from Week 5 of the Learning Network • Extract everything in it into a folder on your machine • Edit the file framed.html using Notepad • Can you work out what it’s meant to do? • You may need to look inside the components it links to • Open framed.html • Does it behave as you expected? • What happens when you resize the window? • Try to understand exactly what’s happening

  17. Frames Exercise • Create a page called xxx.htm (you choose the xxx) • Divide it into three frames: • Split the page vertically into two equal parts • Left initially displays a trivial page you create & call xxxL.htm • Split the Right-hand half horizontally 70:30 • Top 70% of the RH, displays a trivial page called xxxTR.htm • Bottom 30% of the RH is for navigation: store as xxxBR.htm • In Bottom-right frame : • Provide hyperlinks to load target pages into the left-hand and top-right frames • And heavier-duty hyperlinks to replace whole page • Associate graphics with each hyperlink, e.g. arrows • You can base all future frame-sets on this!

  18. HTML Summary • HTML is a pretty small language • You’ve seen most of it already – Frames was all that’s left • Easy to pick up structure from a “good” site on the web,then introduce your own content • Writing your own HTML puts you in control • How pictures and text are related • What happens when you update the page • WYSIWYG tools are getting better, but still leave you guessing – and often generate wasteful HTML • A good HTML tutorial can be found at:http://www.w3schools.com/html/html_intro.asp

  19. Assignment Workshop • Chance to check understanding of: • Document structure <html> <head> </head> <body>… • Basic HTML <hn> <p> <ul> <li> etc • Hyperlinking <a href=…> <a name=…> • Tables <table> <tr> <td> • Handling graphics <img src=…> • Frames <frameset> <frame> • Attributes used inside a tag • Width=, height= not both in an <img> tag! • href=“…” don’t forget http:// in remote links • border=1 • Try to avoid direct reference to presentation • Font, bold, italic

  20. Web Site development Assignment • “Web Site” means a collection of related pages,put together in a logical way • “Development” means you go through a process • Decide what your site is to do • Make a high-level design – what the pieces are and how they should fit together • Design the individual pages and their linkages • Code up the content of the pages • Please don’t use a tool like Front Page • It doesn’t simplify the task of understanding and designing • Does make it easy to produce visually-interesting pages • Doesn’t give you understanding of HTML • And you lose marks

  21. The site itself: One third for design of site, including Success in achieving what you said you set out to do Usability, including ease of navigation between pages One third for “coding” Accuracy – minimal impact from errors Marks awarded for elegant structure Report: One third for report showing evidence of understanding and logical development Clear statement of scope – what is and isn’t included Review of what you discovered in research development Reflection on how you developed your site Marking Scheme Both aspects will be affected by how ambitious you’ve been, but you can usually do better with a simpler site you get right than aiming for the sky and falling short

  22. The Mechanics of Writing HTML • Need at least two windows open: • A browser to test your page in – e.g. Internet Explorer • An editor to update it in – Notepad is fine • Internet Explorer “View source” opens file in Notepad • Can then modify the file, Save it, • Then check the effects in IE • Reality is that most pages are based on existing ones • Get file into Notepad • “Save As” with new name (make sure extension is right ) • Modify the content as you wish – including the Title • You never have to bother typing <HTML> <HEAD> etc

  23. Reminder: Creating Hyperlinks • Any hyperlink reference needs to say what it is linking to • In HTML, we use an Anchor tag with the HREF attribute • <A href="http://www.pdq.edu/freds.htm">Quick Univ</A> • <A href="freds.htm">Local reference</A> • You can reference any resource on the Internet – Just give its URL • Any lack of specificity means “look locally,” so missing out the domain means it is in the local file system • Always leave out as much as you can • Makes it much easier to move the site • Can also use relative references, e.g. to a sub-folder <A href=“./subdir/fred2.htm">relative reference</A>

  24. Some HTML Primers on the Web • The original NCSA primer has been removed, but there’s a printable archive on our web-site • Two good primers are available on-line at: • http://www.w3schools.com/html/html_intro.asp • http://www.web-nation.com/lessons/html-pri.htm • This is Tony Drewry’s clear exposition of HTML tagshttp://www.cems.uwe.ac.uk/~tdrewry/html/index.htm • A very wide-ranging site, covering everything from simple HTML to XML and databases http://www.w3schools.com/ • Any more favourites?

  25. HTML Table Exercise • Starting with the zip file of samples from Week 4 of the web-site (http://www.winchester.ac.uk/bm/ ) • Make a copy of the source on My Documents, preferably with a new name (samples\XXXtable.htm) • Start Windows Explorer and get your file visible on it • Open it with the NOTEPAD Accessory (right-click) • Open it with Internet Explorer (double-click) • Open Firefox and Netscape as well if you have them • You can drag the file from Explorer into each browser • Has anything gone wrong? • Make changes in NOTEPAD, Save, and look at the effect in both the browsers (don’t forget to Refresh/Reload)

More Related