SlideShare a Scribd company logo
Input-Output
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)
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.
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 
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.
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.
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
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 PROGRAM SAMPLEINPUT;       VAR          TEMP : RECORD                FIRST, SECOND : REAL;              END;     BEGIN {Ignore this }     TEMP.FIRST := 5.0E-2;     READLN (TEMP.SECOND);      WRITELN ('THE ANSWER IS', TEMP.FIRST * TEMP.SECOND : 7 : 3)     END.           ~~A. N. Onymous
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.
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.
`+' 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.
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.
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.
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:
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:  ,[object Object]
A ADD, SUB, MUL or DIV-command is executed when the stack contains only one element.
An operation produces a value greater than 30000 in absolute value. ,[object Object]
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''.
Output a blank line after each test case. Sample Input   Sample Output   4 1 2 3 4 0 -2 -6 -12 3 1 2 3 1 11 1998 1 1998 1998 0 Program 1 DUP DUP MUL SUB  Program 2 Impossible  Program 3 Empty sequence
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.
 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:
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. 2
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.
􀂄 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.
􀂄 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.
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.
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
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. ,[object Object],[object Object]
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
   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: ,[object Object]
Unlike memory operations, I/O operations and the CPU are not generally synchronized with each other.,[object Object]
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.
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:
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.
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.
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.
Karen Mae Gomez Nicole Fumey-Nassah Mary Grace Hernandez Neda Marie Maramo Dustin Masangkay IV-Hera Group Members:

More Related Content

What's hot

7 compiler lab
7 compiler lab 7 compiler lab
7 compiler lab
MashaelQ
 
Assembly language
Assembly languageAssembly language
Assembly language
shashank puthran
 
Chapter 2 programming concepts - I
Chapter 2  programming concepts - IChapter 2  programming concepts - I
Chapter 2 programming concepts - I
SHREEHARI WADAWADAGI
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
Sadia Akter
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
Ashwini Sonawane
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
rawan_z
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
Dr. C.V. Suresh Babu
 
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlBca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Rai University
 
Error Recovery strategies and yacc | Compiler Design
Error Recovery strategies and yacc | Compiler DesignError Recovery strategies and yacc | Compiler Design
Error Recovery strategies and yacc | Compiler Design
Shamsul Huda
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
Munni28
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
Kamal Acharya
 
Chapter Three(1)
Chapter Three(1)Chapter Three(1)
Chapter Three(1)
bolovv
 
Spr ch-05-compilers
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilers
Vasim Pathan
 
Assemblers
AssemblersAssemblers
Assemblers
Dattatray Gandhmal
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
Huawei Technologies
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
Dr. Jaydeep Patil
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
marvellous2
 
About Tokens and Lexemes
About Tokens and LexemesAbout Tokens and Lexemes
About Tokens and Lexemes
Ben Scholzen
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c language
kamalbeydoun
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems Programming
Mukesh Tekwani
 

What's hot (20)

7 compiler lab
7 compiler lab 7 compiler lab
7 compiler lab
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Chapter 2 programming concepts - I
Chapter 2  programming concepts - IChapter 2  programming concepts - I
Chapter 2 programming concepts - I
 
The role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler designThe role of the parser and Error recovery strategies ppt in compiler design
The role of the parser and Error recovery strategies ppt in compiler design
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Compiler Design Material
Compiler Design MaterialCompiler Design Material
Compiler Design Material
 
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed controlBca 2nd sem-u-3.1-basic computer programming and micro programmed control
Bca 2nd sem-u-3.1-basic computer programming and micro programmed control
 
Error Recovery strategies and yacc | Compiler Design
Error Recovery strategies and yacc | Compiler DesignError Recovery strategies and yacc | Compiler Design
Error Recovery strategies and yacc | Compiler Design
 
Lexical Analysis
Lexical AnalysisLexical Analysis
Lexical Analysis
 
Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Chapter Three(1)
Chapter Three(1)Chapter Three(1)
Chapter Three(1)
 
Spr ch-05-compilers
Spr ch-05-compilersSpr ch-05-compilers
Spr ch-05-compilers
 
Assemblers
AssemblersAssemblers
Assemblers
 
Compiler Chapter 1
Compiler Chapter 1Compiler Chapter 1
Compiler Chapter 1
 
Compiler Design
Compiler DesignCompiler Design
Compiler Design
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
About Tokens and Lexemes
About Tokens and LexemesAbout Tokens and Lexemes
About Tokens and Lexemes
 
Algorithm and c language
Algorithm and c languageAlgorithm and c language
Algorithm and c language
 
Phases of the Compiler - Systems Programming
Phases of the Compiler - Systems ProgrammingPhases of the Compiler - Systems Programming
Phases of the Compiler - Systems Programming
 

Similar to Input-output

Pascal programming lecture notes
Pascal programming lecture notesPascal programming lecture notes
Pascal programming lecture notes
Alejandro Domínguez Torres
 
Alp 05
Alp 05Alp 05
Alp 05
Jaimon Jacob
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
David Halliday
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
David Halliday
 
Mp lab manual
Mp lab manualMp lab manual
Mp lab manual
Pradeep Kumar
 
Programming basics
Programming basicsProgramming basics
Programming basics
illidari
 
Hello, I need help with the following assignmentThis assignment w.pdf
Hello, I need help with the following assignmentThis assignment w.pdfHello, I need help with the following assignmentThis assignment w.pdf
Hello, I need help with the following assignmentThis assignment w.pdf
namarta88
 
Turbo pascal
Turbo pascalTurbo pascal
Turbo pascal
Vien Rivera
 
INTRODUCCIÓN A LA PROGRAMACIÓN
INTRODUCCIÓN A LA PROGRAMACIÓNINTRODUCCIÓN A LA PROGRAMACIÓN
INTRODUCCIÓN A LA PROGRAMACIÓN
BenjaminAnilema
 
C programming
C programmingC programming
C programming
ASHISH KUMAR
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Mohammed Saleh
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Mohammed Saleh
 
Bitstuffing
BitstuffingBitstuffing
Bitstuffing
Vishal Kr
 
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxCOMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
donnajames55
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
enidcruz
 
Program 1 – CS 344This assignment asks you to write a bash.docx
Program 1 – CS 344This assignment asks you to write a bash.docxProgram 1 – CS 344This assignment asks you to write a bash.docx
Program 1 – CS 344This assignment asks you to write a bash.docx
wkyra78
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
lemonmichelangelo
 
Assembly Language Programming
Assembly Language ProgrammingAssembly Language Programming
Assembly Language Programming
Niropam Das
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
Max Kleiner
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
Anonymous9etQKwW
 

Similar to Input-output (20)

Pascal programming lecture notes
Pascal programming lecture notesPascal programming lecture notes
Pascal programming lecture notes
 
Alp 05
Alp 05Alp 05
Alp 05
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Mp lab manual
Mp lab manualMp lab manual
Mp lab manual
 
Programming basics
Programming basicsProgramming basics
Programming basics
 
Hello, I need help with the following assignmentThis assignment w.pdf
Hello, I need help with the following assignmentThis assignment w.pdfHello, I need help with the following assignmentThis assignment w.pdf
Hello, I need help with the following assignmentThis assignment w.pdf
 
Turbo pascal
Turbo pascalTurbo pascal
Turbo pascal
 
INTRODUCCIÓN A LA PROGRAMACIÓN
INTRODUCCIÓN A LA PROGRAMACIÓNINTRODUCCIÓN A LA PROGRAMACIÓN
INTRODUCCIÓN A LA PROGRAMACIÓN
 
C programming
C programmingC programming
C programming
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Bitstuffing
BitstuffingBitstuffing
Bitstuffing
 
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docxCOMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
COMP 2103X1 Assignment 2Due Thursday, January 26 by 700 PM.docx
 
Lab6: I/O and Arrays
Lab6: I/O and ArraysLab6: I/O and Arrays
Lab6: I/O and Arrays
 
Program 1 – CS 344This assignment asks you to write a bash.docx
Program 1 – CS 344This assignment asks you to write a bash.docxProgram 1 – CS 344This assignment asks you to write a bash.docx
Program 1 – CS 344This assignment asks you to write a bash.docx
 
Basic computer-programming-2
Basic computer-programming-2Basic computer-programming-2
Basic computer-programming-2
 
Assembly Language Programming
Assembly Language ProgrammingAssembly Language Programming
Assembly Language Programming
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
 
lecture 2.pptx
lecture 2.pptxlecture 2.pptx
lecture 2.pptx
 

Recently uploaded

Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
WaniBasim
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Fajar Baskoro
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 

Recently uploaded (20)

Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Liberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdfLiberal Approach to the Study of Indian Politics.pdf
Liberal Approach to the Study of Indian Politics.pdf
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
Pengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptxPengantar Penggunaan Flutter - Dart programming language1.pptx
Pengantar Penggunaan Flutter - Dart programming language1.pptx
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 

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 PROGRAM SAMPLEINPUT;   VAR TEMP : RECORD FIRST, SECOND : REAL; END;   BEGIN {Ignore this } TEMP.FIRST := 5.0E-2; READLN (TEMP.SECOND); WRITELN ('THE ANSWER IS', TEMP.FIRST * TEMP.SECOND : 7 : 3) END. ~~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.
  • 16. A ADD, SUB, MUL or DIV-command is executed when the stack contains only one element.
  • 17.
  • 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  4 1 2 3 4 0 -2 -6 -12 3 1 2 3 1 11 1998 1 1998 1998 0 Program 1 DUP DUP MUL SUB  Program 2 Impossible  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. 2
  • 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.
  • 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.
  • 32.
  • 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 IV-Hera Group Members: