1 / 70

E-Genting Programming Competition 2005

E-Genting Programming Competition 2005. Public Lecture by Jonathan Searcy 21 January 2006. Competition Questions. Failsafe Storage. An application programmer required a small amount of failsafe storage; The storage had to be completely updated or completely unchanged;

Télécharger la présentation

E-Genting Programming Competition 2005

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. E-Genting Programming Competition 2005 Public Lecture by Jonathan Searcy 21 January 2006

  2. Competition Questions

  3. Failsafe Storage • An application programmer required a small amount of failsafe storage; • The storage had to be completely updated or completely unchanged; • If the power failed during a write, the update had to be rolled back.

  4. Failsafe Storage, the Design

  5. Where did the Contestants have Difficulty? • getting the data into and out of the disk files; • calculating and validating the CRC; • evaluating the modulo 232 comparison.

  6. The Nature of Computer Storage

  7. The Nature of Magnetic Storage FM Encoding Scheme for Magnetic Media

  8. What is Formatting?

  9. Which Functions should We Use?

  10. Cyclic Redundancy Check

  11. Modular Arithmetic

  12. Properties of Modulo-2 Arithmetic

  13. What is a CRC?

  14. Hand-Calculating a CRC

  15. CRC(x + CRC(x)) = 0

  16. Structure of the Disk File

  17. Writing to the Disk File

  18. Serial Number Comparison

  19. Two’s Compliment

  20. Comparing Serial Numbers

  21. Selecting the more Recent Serial Number

  22. Coding the Serial Number Comparison

  23. Initialisation Write-function pseudo-code: 1. If the class is not initialised: a. Execute a read cycle to discover the latest serial number and which of the two files was last updated. 2. Increment the serial number. 3. Create a byte array of the data to be written. 4. Write the byte array to the file that was least recently updated.

  24. Summary • The nature of computer storage and thesystem calls for transferring binary data. • The distinction between formatting and input/output. • The nature of a CRC and some of its properties. • The effects of storing data in different sequences. • The nature and consequences of the two’s complement integer format. • Various characteristics of modular arithmetic. • The need to consider initialisation.

  25. Mytel Mobile • Mytel Mobile operates a mobile telephone service. • Subscribers can earn points by making calls on their mobile phones. • Mytel wants to set up a point redemption arrangement with an airline so that its subscribers can exchange points for flights. • To convince the airline to enter into the arrangement, Mytel needs a report that displays the destination and frequency of its subscribers’ flights. • Mytel has a database that contains information about each call, including the identity of the subscriber, the time of the call and the city from which the call was made.

  26. Data Dictionary • date and time the report was generated; • reporting period (from-date and to-date); • for each point balance range: • the point balance range; • number of subscribers; • for each base city: • for each other city: • number of trips; • total number of trips; • totals for all point balance ranges.

  27. Database Schema

  28. Singleton Select

  29. JDBC

  30. Errors that an embedded SQL pre-processor can detect at compile time that raw JDBC calls cannot detect until run time: incorrectly spelled reserved words such as ‘select’ and ‘where’; syntax errors in SQL statements; misspelled column names; ambiguous column names (i.e. a reference to an unqualified column name that is a valid column name in two tables in the query); incompatible database column and host variable data types.

  31. Cursors

  32. Selecting the Base City

  33. Counting Trips

  34. Red Herring

  35. Process for Each Subscriber

  36. But the Call Register is Huge

  37. Parallel Processes

  38. Process Pseudocode

  39. Client and Server-Mode Processes • Client-mode processes execute top-to-bottom. When they need to communicate with another process they call a function to transfer the data. • Server-mode processes wait in an idle state to be called by a client-mode process. When called, they perform whatever function is needed and then return control to the client-mode process.

  40. Client-Client Standoff

  41. Conversion to a Finite State Machine

  42. Summary • Data dictionary interpretation; • Report layout interpretation; • Database accessing using SQL; • Dataflow analysis; • Using parallel processing to overcome serial throughput constraints; • Converting top-to-bottom pseudo-code into an event-driven finite state machine.

  43. Project Scheduling Program • accept an input file name as an argument; • read and analyse the input file; • generate a project schedule listing.

  44. Input File Format

  45. BNF of the Input Syntax

  46. Report Layout

  47. Dataflow Analysis

  48. Token Types • words (keywords, task names, person identifiers, numbers and dates); • strings (task descriptions); • semicolon; • comma; • open brace; • close brace; • end-of-file.

More Related