Скачать презентацию Nizhni Novgorod State University Models and Methods of Скачать презентацию Nizhni Novgorod State University Models and Methods of

Lecture 2.ppt

  • Количество слайдов: 31

Nizhni Novgorod State University Models and Methods of Programming V. A. Grishagin Faculty of Nizhni Novgorod State University Models and Methods of Programming V. A. Grishagin Faculty of Computing Math and Cybernetics Software Department Nizhni Novgorod, Russia 2007 Programming in C Language

Lecture 2. Principles of automatic data processing As we spoke at latter lecture the Lecture 2. Principles of automatic data processing As we spoke at latter lecture the data processing scheme includes the following items: § Initial information § Result information § Algorithm as a sequence of processing operations § Executor who or which performs algorithm operations Since people can not process large amounts of information fast and reliable they use automatic devices, i. e. computers. Now we consider main elements and some theoretical principles of information processing technology on computers. NNSU, 2006 Programming in C Language 2

History of informatics and computers n n n Primitive calculators (abacus) Mechanical machines by History of informatics and computers n n n Primitive calculators (abacus) Mechanical machines by Pascal and Leibnitz Pierre Jacquard - punched card as an information carrier for coding the fabric tracery for weaving machines NNSU, 2006 Programming in C Language 3

First theoretical results n n n Difference and analytical engines by Charles Babbage n First theoretical results n n n Difference and analytical engines by Charles Babbage n Principle of program control n Principle of stored (memorized) program Lady Lovelaice (Lord Byron’s daughter) – first programmer John Bool – boolean algebra n A new class of non-numerical objects possessing two states (values) only n Operations with boolean values NNSU, 2006 Programming in C Language 4

First applied results n James Hollerith n n population census – new technology of First applied results n James Hollerith n n population census – new technology of result processing new system of numeric information coding on punched cards based on binary data representation tabulating machine for automated summing up the data placed on punched cards founder of the IBM Corporation NNSU, 2006 Programming in C Language 5

Computer generations In the 20 -th century up to the end of the thirties Computer generations In the 20 -th century up to the end of the thirties there were no significant events in the development of informatics. The tasks of information processing were successfully solved by means of human resources. But to the middle of the century the amount of data became so large that the humanity could not cope with this problem. Fortunately, that time the development of the science, first of all, physics of electricity created the necessary conditions for constructing computers. The computer evolution may be divided into several stages called generations. Criteria of division may be different but physical basement of electronic schemes or principles of organizing computations are considered for describing generations. NNSU, 2006 Programming in C Language 6

Computer generations In 1937 in the USA Professor Atanassov began at the Iowa University Computer generations In 1937 in the USA Professor Atanassov began at the Iowa University the project aimed at designing a specialized computational machine intended for solving some problems of mathematical physics. He designed first electronic circuits for computer devices. Apparently, Atanassov was the first who used the binary notation for representing numerical information in computers. The Atanassov's machine was not a real computer in our understanding because it could not implement the principle of stored and flexible program. NNSU, 2006 Programming in C Language 7

Mark-1 In 1937 a project of big electromechanical machine was proposed at Harvard University. Mark-1 In 1937 a project of big electromechanical machine was proposed at Harvard University. It was based on relay schemes and allowed to form a computational program using peg boards and switches. This machine was built by the IBM corporation in 1944 and was granted to Harvard University. It was named Mark-1. As Mark-1 did not store the program in the memory it was not a computer in present-day sense. But it is considered sometimes to belong to zero generation computers based on relay circuits. NNSU, 2006 Programming in C Language 8

Computers of the 1 -st generation Computers based on vacuum tubes are the machines Computers of the 1 -st generation Computers based on vacuum tubes are the machines of the 1 -st generation with operating speed about 10 -20 thousand per a second. The computer ENIAC designed in Pennsylvania University (USA) in 1945 is considered to be the first electronic machine with automatic programmed control. The first machine which had all the basic components of modern computers (internal memory, stored and flexible programs) was built in England in 1949 (EDSAC machine). In the Soviet Union in 1947 working out the electronic machine MESM was started and the project was completed in 1951. The other types of 1 -st generation computers were created later for example, SEAC, Univac, IBM-701 in the USA, Atlas in the UK, computers of families BESM, Minsk and Ural in the Soviet Union, etc. NNSU, 2006 Programming in C Language 9

Computers of the 2 -nd generation The 2 -nd generation of computers includes machines Computers of the 2 -nd generation The 2 -nd generation of computers includes machines constructed on the basis of transistors with operating speed about hundreds of thousands operations per a sec. Transistors in comparison with vacuum tubes are much smaller, consumes less energy and are cheaper. NNSU, 2006 Programming in C Language 10

Computers of the 3 -rd generation Appearance of new technologies for producing electronic circuits Computers of the 3 -rd generation Appearance of new technologies for producing electronic circuits based on integrated chips led to creation of next generation in the computer world – the 3 -rd generation. Usage of integrated chips allowed to locate on single crystal of silicon or germanium tens and hundreds electronic circuits. Because of decreasing the hardware dimensions the operating speed increased significantly up to million operations per a sec. Moreover, new technology became an source for creating new types of widely accessible computers – personal ones, because it reduced the price and provided the miniaturization which let to put computer on the table as a home gadget. NNSU, 2006 Programming in C Language 11

Computers of the 4 -th generation Further improvement of technologies for packing electronic circuits Computers of the 4 -th generation Further improvement of technologies for packing electronic circuits on crystals (from thousands to ten million elements on a plate) created new class of integrated chips, so called Very Large-Scale Integration (VLSI). These technologies allowed, on the one hand, to build super-power computers and computational systems consisting of many computational nodes and, on the other hand, to fill all the world with personal computers with powerful capabilities. Now we have new stage of VLSI evolution to Ultra Large Scale Integration (ULSI) where density of packing logical elements amounts to 1 billion elements per a crystal. NNSU, 2006 Programming in C Language 12

Contemporary trends of computer evolution At present moment the potential of condensing elements on Contemporary trends of computer evolution At present moment the potential of condensing elements on crystals is almost exhausted because the distances between elements are close to intermolecular intervals. It is required to propose new principles of designing hardware using, for example, atom structures or biological approaches. What will be in future? Be patient, and you’ll see it. As to real situation there are two main directions of developing computational systems. The first of them is Internet as a global network uniting by means of communication channels hundreds of millions computers all over the world and forming the global information space. NNSU, 2006 Programming in C Language 13

Parallel computations Parallelization is the second way of overcoming the physical restrictions and significant Parallel computations Parallelization is the second way of overcoming the physical restrictions and significant increasing productivity of computers. Parallelization means partitioning a computational problem into several tasks and solving these task simultaneously on different computers: every task on separate computer or processor. If you use n computers and execution times of tasks are close you can speed up problem solving up to n times. This approach requires formation of complex multiprocessor systems. Now there are such systems consisting of hundreds of thousands processors and having the Teraflop peak productivity (1 Teraflop means 1 Billion operation per sec. ) NNSU, 2006 Programming in C Language 14

General scheme of personal computer As to present course in our laboratory works we General scheme of personal computer As to present course in our laboratory works we will use relatively simple computational systems - I mean personal computers working in a local network. They are quite modern and powerful for our goals. The internal structure of computing machines you will study in detail in the course on computer architecture but I would like nevertheless to consider a classical scheme inherent in wide spectrum of computers of different generations beginning from the first one. This scheme is called Von Neumann machine and it was proposed at the end of forties of the past century by the American Von Neumann as a general structure of computer devices and so far is actual, at least, for architecture of personal computers. NNSU, 2006 Programming in C Language 15

General scheme of personal computer Data exchange Control Input device . . . Input General scheme of personal computer Data exchange Control Input device . . . Input device External memory Central Processor Unit (CPU) Random Access Memory (RAM) Output device . . . Output device Data transmission channel NNSU, 2006 Programming in C Language 16

Memory organization Not discussing all the aspects of separate computer units we dwell more Memory organization Not discussing all the aspects of separate computer units we dwell more detailed on the memory structure because organization of storing information is very important for understanding the programming process. In general case the memory may be considered to be a set of cells numbered successively by integer numbers beginning from zero. Number of the cell is its address. The CPU uses the cell address for access to information stored in the cell. Cells . . . 0 1 2 3 4 5 6 M-1 M Addresses NNSU, 2006 Programming in C Language 17

Cell structure Every cell consists of several bits and each of them can be Cell structure Every cell consists of several bits and each of them can be in two different states only, one state is denoted by the sign zero, other – by the sign 1. So, one bit represents minimal unit of information. Such coding is called binary. The cell of 8 bits is called byte. For the most of computers byte memory architecture are typical. High-order bit 1 0 0 0 1 Lower bit Bit elements of the cell are numbered from right to left. The right bit (called lower order bit) has the number 0 and the left bit is called high-order bit or most significant bit. How is the different kinds of information represented in the cells? For doing this it is necessary to define the rule of mapping the set of information elements onto the set of binary combinations. Of course, the numbers of elements in this sets must be equal or, at least, the cardinal number of the information element set does not exceed the number of possible binary combinations. NNSU, 2006 Programming in C Language 18

Coding symbolic information A simple example: symbolic information Consider such sort of data as Coding symbolic information A simple example: symbolic information Consider such sort of data as symbolic information. How many different binary combination are there if we take a byte cell? The answer is 28 = 256. Therefore, we may take 256 different symbols and agree upon what binary combination will correspond to certain symbol. Such way is provided by so called code tables. One of the most popular is the ASCII table (American Standard Code for Information Interchange) but there are many others. NNSU, 2006 Programming in C Language 19

Coding the integer numbers The second example: integer numbers It is known that numbers Coding the integer numbers The second example: integer numbers It is known that numbers may be written in systems of numerical notation with different radices (bases). Usually we apply decimal system but it is possible to represent numbers in binary system (with the radix 2) where only two digits 0 and 1 exist. What is the rule of coding? We take an integer number, transform it to binary system and just consider digits as values of corresponding bits. In the byte cell we can write 256 different integer numbers. For instance, we can take numbers from 0 to 255. Another rule. Let the high-order bit denote the sign of the number: if it is equal to zero the number is positive, if to 1 then negative. In the cell we can deal with 7 bits for representing number value and we have 27=128 combination at our disposal. So, in this way we can code 127 positive, 127 negative integer numbers and zero. NNSU, 2006 Programming in C Language 20

Technologies of task solving So we have considered the hardware evolution and briefly discussed Technologies of task solving So we have considered the hardware evolution and briefly discussed modern state-of-the-art. Next important question is what should we do to solve a task using computer? Together with development of hardware the technologies of the user’s work on computer changed too. Let’s briefly consider how programmers used computer earlier, what work environment they had for program development and execution. NNSU, 2006 Programming in C Language 21

Low-level technologies Working on computers of the 1 -st generation programmer had at his Low-level technologies Working on computers of the 1 -st generation programmer had at his disposal the machine code only for programming. No algorithmic languages, no editors for preparation of program text, no operating systems for work management – that was the reality of programmer’s life. All the programs were written in primitive machine commands using binary system of coding (rather, more convenient octal or hexadecimal notation). Programmer had to transform decimal number to binary numbers because the central processor “understood” binary representation of information only. There were no monitors, keyboards for data input, initial information and program were coded in binary form on punch cards and results were printed on narrow paper tape in octal or special binary-decimal form. All computer resources were at total programmer’s disposal and machine was under “manual” user’s management. It was very convenient for programmer because he could quickly find errors and right away run the program once and once again. Unfortunately, while programmer was thinking the expensive computer equipment was standing idle. NNSU, 2006 Programming in C Language 22

Low-level program A small example of the program in machine code of a computer Low-level program A small example of the program in machine code of a computer of the 1 st generation. The program for convenience has been written in octal form but on punched cards and in the memory it is represented in binary code. 01 2315 3422 3423 05 3423 2314 7712 02 7712 3423 7712 44 7712 0000 7713 77 0000 NNSU, 2006 Programming in C Language 23

Batch technologies This situation was very prodigal and on the machines of the 2 Batch technologies This situation was very prodigal and on the machines of the 2 -nd generation the organization of computer functioning was cardinally changed: users were separated from computer. Instead a batch mode was introduced when operator formed a program package consisting of several programs and initiated their serial execution. In this mode for the first time special cards which contained operations controlling the process of program execution were introduced for the first time. The set of such operations was the first primitive language of machine job control. Moreover, that scheme required to create programs not for processing information but for control of program execution. For the first time all the programs were divided into 2 groups: system software for control of computer functioning and applied programs performing user’s task. It may be said that programs implementing batch mode were the first tiny operating systems. At that time first high-level algorithmic languages (FORTRAN, BASIC, Algol) were proposed. They provided a new technology of algorithm coding which was more convenient for program development and increased significantly the programmers’ labor productivity. NNSU, 2006 Programming in C Language 24

Dialog interaction Along with development of hardware batch mode was developed too and gradually Dialog interaction Along with development of hardware batch mode was developed too and gradually a system language appeared for controlling the work on computer. It was complicated enough and the Job Control Language (JCL) for computers of the system IBM-360/370 should be mentioned as a summit of this direction. The appearance in computational systems of the 3 -rd generation such new device as monitor with keyboard changed process of interaction between man and computer. It allowed to realize a new control mode based on dialog interaction. It required creating new types of operating systems. The most known of them was widespread Disk Operating System (DOS) for personal computers IBM PC. Interaction of man and computer took place through command line where user input the control commands (directives). NNSU, 2006 Programming in C Language 25

Dialog interface Command line is not convenient tool for working because it supposes knowledge Dialog interface Command line is not convenient tool for working because it supposes knowledge of the directive language and has no visual form. For overcoming this disadvantage the shell Norton Commander was proposed. It provided some visual access to file system of computer and simple and convenient operations with files. NNSU, 2006 Programming in C Language 26

OS Windows The ideas of visual interaction which does not require learning a control OS Windows The ideas of visual interaction which does not require learning a control language like DOS one have been developed and realized in contemporary operation system Windows created by the Microsoft Corporation – one of the leading participants of the software market. The success secret consisted in clear understanding what people need when they work on computer and how to overcome existing problems. Microsoft proposed new technology of interaction so called “desktop technology” which modeled customary scheme of working with documents. For working in the Windows it is necessary to know a small set of simple operations using keyboard and mouse only and these actions are analogous to usual operations in non-computer world. Of course, there are other operating systems with the interface like that (and Microsoft was not the first which proposed it) but Windows is used in the most mass segment of computer market – the segment of personal computers and, therefore, is so popular. NNSU, 2006 Programming in C Language 27

Software for program development Tools for program elaboration evolved along with the hardware development Software for program development Tools for program elaboration evolved along with the hardware development and passed the way from manual programming in machine code to modern technologies on the basis of high-level programming languages. In this way there were different program systems supporting the process of program development and execution. Of course, these systems corresponded to available mode of computer functioning. Now we have got powerful tools for writing, linking, executing and debugging complicated programs in high-level algorithmic languages. These tools are called Integrated Development Environments (IDE). We will use the Microsoft Visual Studio. NET platform as IDE for making C programs. It will be considered later but in any case the process of program development in the IDE may be described in the following diagram form. NNSU, 2006 Programming in C Language 28

Scheme of program development Text Compilator editor Preparation of program text Program in algorithmic Scheme of program development Text Compilator editor Preparation of program text Program in algorithmic language Program compilation Compilator messages Are there compilation errors? Program in machine code No Initial data Start Input Yes Correction of the program NNSU, 2006 Program execution System messages Output results Are there Yes execution errors? No Analysis of results Text editor C P U No Programming in C Language Are results correct? Yes Finish 29

Contacts 603950, Nighni Novgorod Gagarina av. , 23, Nizhny Novgorod State University, Applied Mathematics Contacts 603950, Nighni Novgorod Gagarina av. , 23, Nizhny Novgorod State University, Applied Mathematics and Cybernetics faculty Tel: +7 (831) 4654859 E-mail: vagris@unn. ac. ru NNSU, 2006 Programming in C Language 30

Thank you for attention n Questions, n Remarks, n NNSU, 2006 Comments Programming in Thank you for attention n Questions, n Remarks, n NNSU, 2006 Comments Programming in C Language 31