Your SlideShare is downloading. ×
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply



Published on

Powerpoint Presentation for our Computer Report last 4th Year

Powerpoint Presentation for our Computer Report last 4th Year

Published in: Education, Technology

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide


  • 1. Input-Output
  • 2. is a feature of modern computers and microprocessors that allows certain hardware subsystems within the computer to access system memory for reading and/or writing independently of the central processing unit. Many hardware systems use DMA including disk drive controllers, graphics cards, network cards and sound cards. DMA is also used for intra-chip data transfer in multi-core processors, especially in multiprocessor system-on-chips, where its processing element is equipped with a local memory (often called scratchpad memory) and DMA is used for transferring data between the local memory and the main memory. Computers that have DMA channels can transfer data to and from devices with much less CPU overhead than computers without a DMA channel. Similarly a processing element inside a multi-core processor can transfer data to and from its local memory without occupying its processor time and allowing computation and data transfer concurrency.
    Direct memory access (DMA)
  • 3. Without DMA, using programmed input/output (PIO) mode for communication with peripheral devices, or load/store instructions in the case of multicore chips, the CPU is typically fully occupied for the entire duration of the read or write operation, and is thus unavailable to perform other work. With DMA, the CPU would initiate the transfer, do other operations while the transfer is in progress, and receive an interrupt from the DMA controller once the operation has been done. This is especially useful in real-time computing applications where not stalling behind concurrent operations is critical. Another and related application area is various forms of stream processing where it is essential to have data processing and transfer in parallel, in order to achieve sufficient throughput.
  • 4. Your local computer user's group publishes a quarterly newsletter, and in each issue there is a small Turbo Pascal programming problem to be solved by the membership. Members submit their solutions to the problem to the newsletter editor, and the member submitting the shortest solution to the problem receives a prize.
     Pascal Program Lengths 
  • 5. The length of a program is measured in units. The unit count is determined by counting all occurrences of reserved words, identifiers, constants, left parentheses, left brackets, and the following operators: +, -, *, /, =, <, >, <=, >=, <>, @, ^, and :=. Comments are ignored, as are all other symbols not falling into one of the categories mentioned above. The program with the lowest unit count is declared the winner. Two or more programs with equal unit counts split the prize for the quarter.
  • 6. In an effort to speed the judging of the contest, your team has been asked to write a program that will determine the length of a series of Pascal programs and print the number of units in each.
  • 7. Input to your program will be a series of Turbo Pascal programs. Each program will be terminated by a line containing tilde characters in the first two columns, followed by the name of the submitting member. Each of these programs will be syntactically correct and use the standard symbols for comments (braces) and subscripts (square brackets).
    Input and Output
  • 8. For each program, you are print a separate line containing the name of the submitting member and the unit count of the program. Use a format identical to that of the sample below.
    Sample input
      BEGIN {Ignore this }
    TEMP.FIRST := 5.0E-2;
    ~~A. N. Onymous
  • 9. Sample output
    Program by A. N. Onymous contains 29 units.
    Note: Here are some additional notes on Turbo Pascal for those not familiar with the language:
    Identifiers start with an underscore (_) or a letter (upper or lower case) which is followed by zero or more characters that are underscores, letters or digits.
     The delimiter for the beginning and ending of a string constant is the single forward quote ( ‘ ). Each string is entirely on a single source line (that is a string constant cannot begin on one line and continue on the next). If ‘ ‘ appears within a string then it represents a single ‘ character that is part of the string. A string constant consisting of a single ' character is, therefore, represented by ‘ ‘ ‘ ‘ in a Turbo Pascal program. The empty string is allowed.
  • 10. The most general form of a numeric constant is illustrated by the constant 10.56E-15. The 10 is the integral part (1 or more digits) and is always present. The .56 is the decimal part and is optional. The E-15 is the exponent and it is also optional. It begins with an upper or lower case E, which is followed by a sign (+ or -). The sign is optional.
    Turbo Pascal supports hexadecimal integer constants which consist of a $ followed by one or more hex digits (`0' to `9', `a' to `f', `A' to `F'). For example, $a9F is a legal integer constant in Turbo Pascal.
    The only comment delimiters that you should recognise are {}, and not (**). Comments do not nest.
  • 11. `+' and `-' should be considered as operators wherever possible. For example in x := -3 the `-' and the `3' are separate tokens.
    Subranges of ordinal types can be expressed as lower..upper. For example, 1..10 is a subrange involving the integers from 1 to 10.
    All tokens not mentioned anywhere above consist of a single character.
  • 12. Optimal Programs 
    As you know, writing programs is often far from being easy. Things become even harder if your programs have to be as fast as possible. And sometimes there is reason for them to be. Many large programs such as operating systems or databases have ``bottlenecks'' - segments of code that get executed over and over again, and make up for a large portion of the total running time. Here it usually pays to rewrite that code portion in assembly language, since even small gains in running time will matter a lot if the code is executed billions of times.
  • 13. In this problem we will consider the task of automating the generation of optimal assembly code. Given a function (as a series of input/output pairs), you are to come up with the shortest assembly program that computes this function.
    The programs you produce will have to run on a stack based machine, that supports only five commands: ADD, SUB, MUL, DIV and DUP. The first four commands pop the two top elements from the stack and push their sum, difference, product or integer quotient1 , respectively, on the stack. The DUP command pushes an additional copy of the top-most stack element on the stack.
  • 14. So if the commands are applied to a stack with the two top elements a and b (shown to the left), the resulting stacks look as follows:
  • 15. At the beginning of the execution of a program, the stack will contain a single integer only: the input. At the end of the computation, the stack must also contain only one integer; this number is the result of the computation.
    There are three cases in which the stack machine enters an error state:
    • A DIV-command is executed, and the top-most element of the stack is 0.
    • 16. A ADD, SUB, MUL or DIV-command is executed when the stack contains only one element.
    • 17. An operation produces a value greater than 30000 in absolute value.
  • Input
    The input consists of a series of function descriptions. Each description starts with a line containing a single integer n ( ), the number of input/output pairs to follow. The following two lines contains n integers each: in the first line (all different), and in the second line. The numbers will be no more than 30000 in absolute value.
    The input is terminated by a test case starting with n = 0. This test case should not be processed.
  • 18. Output
    You are to find the shortest program that computes a function f , such that f(xi) = yi for all . This implies that the program you output may not enter an error state if executed on the inputs xi (although it may enter an error state for other inputs). Consider only programs that have at most 10 statements.
    For each function description, output first the number of the description. Then print out the se- quence of commands that make up the shortest program to compute the given function. If there is more than one such program, print the lexicographically smallest. If there is no program of at most 10 statements that computes the function, print the string `` Impossible''. If the shortest program consists of zero commands, print ``Empty Sequence''.
  • 19. Output a blank line after each test case.
    Sample Input 
    Sample Output 
    1 2 3 4
    0 -2 -6 -12
    1 2 3
    1 11 1998
    Program 1
    Program 2
    Program 3
    Empty sequence
  • 20.
  • 21. An SPSS data file is a binary file that contains the case data on which SPSS operatesand a dictionary describing the contents of the file. Many developers havesuccessfully created applications that directly read and write SPSS data files. Some ofthese developers have asked for a module to help them manipulate the rather complexformat of SPSS data files. The I/O Module documented in this appendix is designedto satisfy this need.
  • 22. Read and write SPSS data files
    Set general file attributes, create variables
    Set values for variables
    Read cases
    Copy a dictionary
    Append cases to an SPSS data file
    Directly access data
    You can use the I/O Module to:
  • 23. Developers can call SPSS I/O Module procedures in client programs written in C,Visual Basic, and other programming languages. It is necessary to include the headerfile spssdio.h. The specific calling conventions are __pascal for 16-bit programs and__stdcall for 32-bit programs. The __stdcall conventions are compatible withFORTRAN, although calling I/O Module procedures is not specifically supported forFORTRAN programs.
    This appendix outlines the steps for developing an application using the I/O
    Module procedures. It also contains a description of each procedure.
    The I/O Module files are on the CD-ROM in /SPSS/developer/IO_Module.
  • 24. New I/O Module for SPSS 14.0
    The I/O Module was completely rewritten for SPSS 14.
    􀂄 The new architecture should facilitate further development. However, much of thecode is not used in the SPSS product itself and has not received as much testing asthat in the predecessor module.
    􀂄 An unintended but necessary limitation of the new module is that thespssOpenAppend function will not work correctly on compressed data files createdby SPSS systems prior to release 14.
  • 25. 􀂄 To assist in the handling of non-western character sets, we are now using IBM'sInternational Components for Unicode or ICU. As a result, the I/O Moduledepends on ICU runtime libraries, which are included on the CD-ROM.
    􀂄 The I/O Module now uses the Microsoft Resident C Runtime. If the clientapplication shares this run-time, it will also share the locale. As a result, any callto spssSetLocale will affect both the I/O Module and the client. Such a call isunnecessary if the client has already set the locale. When the module is loaded, itsets the locale to the system default.
  • 26. 􀂄 Prior to SPSS 14.0.1, the name of the multiple response set specified forspssAddMultRespDefC or spssAddMultRespDefN was limited to 63 bytes, and theI/O Module automatically prepended a dollar sign. In the interest of consistency,the name is now limited to 64 bytes and must begin with a dollar sign. Also, thelength of the set label was previously limited to 60 bytes. It may now be as long asa variable label, 255 bytes.
  • 27. The temporary stopping of the current program routine, in order to execute some higher priority I/O subroutine, is called an interrupt. The interrupt mechanism in the CPU forces a branch out of the current program routine to one of several subroutines, depending upon which level of interrupt occurs.
    I/O operations are started as a result of the execution of a program instruction. Once started, the I/O device continues its operation at the same time that the job program is being executed. Eventually the I/O operation reaches a point at which a program routine that is related to the I/O operation must be executed. At that point an interrupt is requested by the I/O device involved. The interrupt action results in a forced branch to the required subroutine.
  • 28. In addition to the routine needed to start an I/O operation, subroutines are required to:
    Transfer a data word between an I/O device and main storage (for write or read operations)
    Handle unusual (or check) conditions related to the I/O device
    Handle the ending of the I/O device operation
  • 29. Note: Some I/O devices do not require program-instruction handling of data transfers to or from core storage. These devices are described in subsequent sections of this book. Their method of transferring data is called cycle steal and is not related to the interrupt program-subroutine method of handling data described in this section.
    • In order to understand the interrupt scheme, first examine the start of an I/O operation. Then contrast this operation with an interrupt occurrence, which in many respects is similar to the beginning of the I/O operation.
  • 30. In our discussion of the memory hierarchy, it was implicitly assumed that memory in the computer system would be ``fast enough'' to match the speed of the processor (at least for the highest elements in the memory hierarchy) and that no special consideration need be given about how long it would take for a word to be transferred from memory to the processor -- an address would be generated by the processor, and after some fixed time interval, the memory system would provide the required information. (In the case of a cache miss, the time interval would be longer, but generally still fixed. For a page fault, the processor would be interrupted; and the page fault handling software invoked.)
    Input-Output Architecture
  • 31. Although input-output devices are ``mapped'' to appear like memory devices in many computer systems, I/O devices have characteristics quite different from memory devices, and often pose special problems for computer systems. This is principally for two reasons:
    • I/O devices span a wide range of speeds. (e.g. terminals accepting input at a few characters per second; disks reading data at over 10 million characters / second).
    • 32. Unlike memory operations, I/O operations and the CPU are not generally synchronized with each other.
  • Figure  shows the general I/O structure associated with many medium-scale processors. Note that the I/O controllers and main memory are connected to the main system bus. The cache memory (usually found on-chip with the CPU) has a direct connection to the processor, as well as to the system bus.
    Figure: A general I/O structure for a medium-scale processor system
  • 33. Note that the I/O devices shown here are not connected directly to the system bus, they interface with another device called an I/O controller. In simpler systems, the CPU may also serve as the I/O controller, but in systems where throughput and performance are important, I/O operations are generally handled outside the processor.
    Until relatively recently, the I/O performance of a system was somewhat of an afterthought for systems designers. The reduced cost of high-performance disks, permitting the proliferation of virtual memory systems, and the dramatic reduction in the cost of high-quality video display devices, have meant that designers must pay much more attention to this aspect to ensure adequate performance in the overall system.
  • 34. Because of the different speeds and data requirements of I/O devices, different I/O strategies may be useful, depending on the type of I/O device which is connected to the computer. Because the I/O devices are not synchronized with the CPU, some information must be exchanged between the CPU and the device to ensure that the data is received reliably. This interaction between the CPU and an I/O device is usually referred to as ``handshaking''. For a complete ``handshake,'' four events are important:
  • 35. The device providing the data (the talker) must indicate that valid data is now available.
    The device accepting the data (the listener) must indicate that it has accepted the data. This signal informs the talker that it need not maintain this data word on the data bus any longer.
    The talker indicates that the data on the bus is no longer valid, and removes the data from the bus. The talker may then set up new data on the data bus.
    The listener indicates that it is not now accepting any data on the data bus. the listener may use data previously accepted during this time, while it is waiting for more data to become valid on the bus.
  • 36. Note that each of the talker and listener supply two signals. The talker supplies a signal (say, data valid, or DAV) at step (1). It supplies another signal (say, data not valid, or   ) at step (3). Both these signals can be coded as a single binary value (DAV) which takes the value 1 at step (1) and 0 at step (3). The listener supplies a signal (say, data accepted, or DAC) at step (2). It supplies a signal (say, data not now accepted, or   ) at step (4). It, too, can be coded as a single binary variable, DAC. Because only two binary variables are required, the handshaking information can be communicated over two wires, and the form of handshaking described above is called a two wire Handshake. Other forms of handshaking are used in more complex situations; for example, where there may be more than one controller on the bus, or where the communication is among several devices. Figure  shows a timing diagram for the signals DAV and DAC which identifies the timing of the four events described previously.
  • 37. Figure: Timing diagram for two-wire handshake
    Either the CPU or the I/O device can act as the talker or the listener. In fact, the CPU may act as a talker at one time and a listener at another. For example, when communicating with a terminal screen (an output device) the CPU acts as a talker, but when communicating with a terminal keyboard (an input device) the CPU acts as a listener.
  • 38. Karen Mae Gomez
    Nicole Fumey-Nassah
    Mary Grace Hernandez
    Neda Marie Maramo
    Dustin Masangkay
    Group Members: