700 likes | 719 Views
Explore failsafe storage and programming techniques for data integrity and reliability. Learn about CRC, modular arithmetic, disk file structure, and project scheduling. Understand the design challenges and implementation details crucial for secure storage systems.
E N D
E-Genting Programming Competition 2005 Public Lecture by Jonathan Searcy 21 January 2006
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.
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.
The Nature of Magnetic Storage FM Encoding Scheme for Magnetic Media
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.
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.
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.
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.
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.
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.
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.
Project Scheduling Program • accept an input file name as an argument; • read and analyse the input file; • generate a project schedule listing.
Token Types • words (keywords, task names, person identifiers, numbers and dates); • strings (task descriptions); • semicolon; • comma; • open brace; • close brace; • end-of-file.