Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
How modern computer is built? Modern computers have been perceived first of all as computing (calculating) tools We will discuss digital computers, as the analog and hybrid machines are very rarely used nowadays. Construction of modern digital computers was described in memos written by John von Neumann (American mathematician of Hungarian origin) in 1945. It is still known as „von Neumann architecture”. Memory is a device capable to store numbers (at when it is on). It is built of numbered cells and these latter numbers are known as their addresses. CPU is a device storing data (taken from respective addresses in memory) temporarily in registers and performing on them simple arithmeric operations. Then – sending them back to memory. Computer Science EPM/03 1 Bus (in Polish) - magistrala 1 How numbers can become commands? It is quite understandable that data and addresses are numbers. The example below illustrates how numbers can become commands. In a CPU it is a bit more complex, but the robot below (a cube with six propellers capable of moving in a 3D space under no gravity conditions) illustrates the principle rather well. Propeller No. (0-off,1-on) direction of movement 5 4 3 2 1 0 0 0 0 0 0 0 stop 0 0 0 1 0 0 forward 0 0 1 0 0 0 backward 1 0 1 0 0 0 back/rightward 1 0 0 0 1 up/leftward, etc. 0 Computer Science EPM/03 2 2 How numbers are represented in computers? Today numbers are most frequently written using positional system with base ten. Base ten means that ten digits are used to compose numbers using certain rules. Digits are symbols (usually graphical) corresponding to certain, always the same number of objects, without any regard to the number of these objects. (describing the size of small sets). In childhood we were taught by imprinting that two sweets, two bunnies, etc., we should associate with symbol 2. In a positional system, however, the value represented by a digit may vary, depending on its position in a number. This is best represented by the formula: N = ∑ Di wi = ∑ Di B i where: N is the value of a number, Di is absolute value of the digit at ith position, wi is weight of this position, equal to base of the system B raised to power i. When integers are expressed in this manner, position zero is the rightmost one, while in the case of real numbers, position zero is that of digit with decimal separator at its right side. Notice the role of zero in positional systems. Computer Science EPM/03 3 3 How numbers are represented in computers? (2) N = ∑ Di wi = ∑ Di B i Let’s see how it works: 117 = 1×102+1×101+7×100=100+10+7=117 23,75=2×101+1×100+7×10–1+5×10–2 In other positional systems (indicated in subscripts): base 4 (quarternary) 1134=1×42+1×41+3×40=1610+410+310=2310 base 7 6027=6×72+0×71+2×70=29410+010+210=29610 base 2 (binary) 10010102=26+23+21=7410 base 16 (hexadecimal) AF16=(10×161+15×160)10=17510 In the last system capital letters A through F serve as digits representing values from 10 to 15. Computer Science EPM/03 4 4 How numbers are represented in computers? (3) Usage of the binary system in digital computers was also suggested in von Neumann’s memos. It has its advatages and disadvatages: • numbers are very long (require much storage space and cause sending transfer problems (–) • only two digits are necessary (+). It was a decisive argument as „electronic symbols” (electronic digits) had to be created. • binary system is compatible with different information carriers (+): optical – light 1, darkness 0; mechanical – hole 1, no hole 0 (punched cards and perforated tapes); magnetic, etc. The formula we used may be easily adopted to binary system, expressing unsigned integers : N = ∑ Di 2 i Computer Science EPM/03 5 5 How numbers are represented in computers? (4) The smallest imaginable unit used in data storage and transfer transfer is hence, a binary digit know as a BIT (binary digit, it is also the smallest piece of information). Addressing such a small units would be difficult. Hence, a practical unit is a byte, which consists of eight bits taken together. 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 One byte represents just a single unsigned integer from 0 (left) to 255 (right), which means 256 different values. If we want to include negative numbers, we must sacrifice one bit to bear the sign (here leftmost one, normally weight 128, most significant bit): 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 –127 +127 Computer Science EPM/03 6 6 How numbers are represented in computers? (5) In the latter case one byte can carry only 255 different values, additionally creating ambiguity: 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 –0 ?? +0 ?? To solve those issues, a modification was introduced to the binary system, known as the two’s complement system. The formula is modified as follows: N = −2 n + ∑ Di 2i 0 1 1 1 1 1 1 1 127 1 1 1 1 1 1 1 1 –1 0 1 1 1 1 0 0 0 120 1 1 1 1 1 0 0 0 –8 0 0 0 0 0 1 0 1 5 1 0 0 0 0 1 0 1 –123 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 –128 256 different values (from –128 to +127), no „zero” ambiguity: Computer Science EPM/03 7 Two’s complement (in Polish) – uzupełnienie do dwójki (U2 – no kidding!). 7 How numbers can become commands? (2) Returning to the example of our cube-robot, if we treat the propeller number as the position of the byte, we can find numbers sent to the robot forcing it to execute specific movements: Propeller No. (0-off,1on) direction of movement number sent (unsigned) 5 4 3 2 1 0 0 0 0 0 0 0 stop 0 0 0 0 1 0 0 forward 4 0 0 1 0 0 0 backward 8 1 0 1 0 0 0 back/rightward 40 0 1 0 0 0 1 up/leftward 17 Computer Science EPM/03 8 8 How numbers are represented in computers? (6) Obviously, we cannot be restricted to using only small integers (even signed). Hence, all each variable used in computer programming is declared as being of certain „type”, which automatically explains what kind of information it carries, how many bytes it uses and how the bytes should be understood (combined) by the computer. For example using 2 bytes, arranged as shown below, we can cover values from 0 to 65535 in the unsigned system and from –32768 to +32767 in the two’s complement system. 1 0 1 1 0 0 0 0 1 1 1 1 1 1 1 1 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 more significant byte (MSB) less significant byte (LSB) –20225 Computer Science EPM/03 9 9 How numbers are represented in computers? (7) For real numbers more bytes are needed. Part of them cover the significant digits (the mantissa) and part of them the exponent. When a variable is declared as being of certain type (e.g. Real – 4 bytes), only limited number of significant digits may be stored. This may lead to numerical instability in certain calculations. If we want more significant digits, we must declare types using more bytes – requiring more space in memory and handled longer by the CPU. For special purposes, like calculating milions of digits in Pi number, quite different principles must be used. Bytes are also used as a measure of storage devices capacity. They are very small units, hence, multiple units are introduced: 1 kByte = 210 Bytes = 1024 Bytes 1 MByte = 1024 kBytes = 1048576 Bytes 1 Gbyte = 1024 Mbytes = 1048576 kBytes = 1073741824 Bytes Computer Science EPM/03 10 10 Non-numerical information in digital computers Most important non-numerical information in computers are text data. It has been achieved long ago by simple ascribing characters to numbers or viceversa. First such system is known as ASCII (American Standard Code for Information Interchange). It has been developed for usage in teletypes and originally used only 7 bits, permitting to carry only 128 characters, including 32 steering commands (like Line Feed 10 or Carriage Return 13). N C 32 N C N C N C N C N C N C 38 & 44 , 50 2 56 8 62 > 68 D 33 ! 39 ‘ 45 – 51 3 57 9 63 ? 69 E 34 ” 40 ( 46 . 52 4 58 : 64 @ 70 F 35 # 41 ) 47 / 53 5 59 ; 65 A 71 G 36 $ 42 * 48 0 54 6 60 < 66 B 72 H 37 % 43 + 49 1 55 7 61 = 67 C 73 I Computer Science EPM/03 11 This is only a part of the ASCII code. 11 Non-numerical information in digital computers (2) Nowadays even an 8-bit ASCII (256 characters and seering commands) is too small to cover all the symbols used in different fields of human activity. Hence a 2 byte system was adopted, permitting to embrace 65536 characters. Yet some more exotic languages (using non Latin characters) must use special variants of this system. Variables carrying text data are known as strings (String type). Usually, the first byte or bytes indicate the lenght of the string and successive bytes carry the characters. Dynamic strings of no predefined length are also used. Notice, that ASCII code is „constructed” in a way facilitating operations like comparison of strings, ordering in alphabetical order: upper case letters are represented by smaller numbers (codes) then the lower case letters. All these operations are reduced to subtraction of consecutive characters in the string. Other types of non-numerical information will be discussed later. Computer Science EPM/03 12 12 Peripheral devices Computer minimum – as described before – was a very user unfriendly device. Input of programs and data required manual switching (0, 1) in binary. Reading out the output also required writing down which bulbs are on (1) and which dark (0). Then, another tedious job was translation of all this stuff into easily readable decimal numbers. For this and other reasons, computer minimum started growing, i.e., additional devices were added to it to facilitate working with the computer. First, permanent external memories were added to avoid loading the program manually every time. Also, output could be stored for future use. Those memories were magnetic, first tape, later disc (easier access to any point of the storage space – surface). Second, methods of input and output had to be improved. For the first purpose, teletypes were employed directly or via pyunched tape (output was already in binary – ASCII). For the second – printers – producing a hardcopy od the output, preceded by binary to decimal translation. It was the situation with big mainframe computers. Computer Science EPM/03 13 13 Peripheral devices (2) Since those days, especially with appearance of PCs, many other peripheral or I/O devices were added. Let’s name some of them: name function name function Monitor (screen) O (I/O) Scanners I keyboard I Modem or net card I/O mouse I Camera I loudspeakers O ADC I earphones O DAC O printers O Pen drives I/O Computer Science EPM/03 14 14 Operating systems It is not enough to connect physically all these devices to the computer. It must know how to use them. Hence, each device is accompanied by a driver, which is a short program telling the computer how to use this specific device. For example, if you buy a printer, you must usually install it, meaning to load the driver into the computer operating system. If you use a new pen drive with your computer, you must wait a minute to let the computer familarize with the new device (the driver is on the pen drive). All drivers for those I/O devices which are customary included in the basic configuration of a computer (memory discs, screen, keyboard, mouse), along with some features making the whole system capable to run several tasks (applications) parallelly and user friendly (user-computer interface) constitute this computer operating system. It is also a program, or even a set of programs, which the computer loads automatically from the disc memory after switching it on (booting). Computer Science EPM/03 15 15 Operating systems (2) Most popular operating systems are: • UNIX and its family (big computers) • OS 2 and successors (original IBM PC) • Microsoft family: DOS, Windows (all PCs but Apple) • Apple (Apple DOS, Mac DOS) concept of graphical interface • Linux – open system, which may be improved by the users. Main actions of operating systems are: • planning time of CPU usage by different tasks (programs running at the same time) • controlling the usage of RAM by different tasks (assigning the space to them) • controlling communication between the tasks • controlling and assigning the access to the I/O devices by different tasks • controlling the file system Computer Science EPM/03 16 16 Operating systems (3) Each operating system consists of: • the kernel (the core of the system executing the control tasks) • the shell (enabling communication between the user and the computer) • the system of files. File is a sequence of data (bytes) of finite length, having a name and some attributes. Such data set is treated by the OS as a single entity. Types of files (general): • catalogues (folders, directories) – contain other folders or files • symbolic links • executable files • queues. Computer Science EPM/03 17 17 Files and their organization. File is a sequence of data of finite length, having a name and some attributes. Such data set is treated by the OS as a single entity. Attributes of files: • read – only, • hidden • system • archive • folder, directory • volume • coded (Windows only) • compressed (Windows only) • offline (Windows only) • temporary (Windows only). Computer Science EPM/03 18 18 Files and their organization (2) File names are built of two parts: proper name and extension. They are separated by a dot (point, period). Nowadays proper names may be up to 64, 128 or even 255 character long – which is impractical, though better than before, when they were restricted to 8 characters (usage of some charcters is forbidden). Extensions are up to 3 characters (rarely 4 in net applications). Types of files (detailed, indicated by their extensions): • *.exe (executable file – containing a program), • *.sys; *.dll; *.ini; *.drv (system files used by the OS or by several programs – common files) • *.txt („pure” text or ASCII files) • *.bmp; *.jpg; *.tif; *gif (graphics in different • *.doc (MSWord documents) • *.xls (MSExcel documents) • *.ppt (MSPowerPoint documents) • *.mp3 (sound containing documents) • *.zip; *.rar (archive files – packed), • *.pdf portable document format (Adobe Reader), Changing the extensions is not recommended (sometimes even forbidden). Computer Science EPM/03 19 OSs still recognize the filetype by their extensions not the contents. 19 Files and their organization (3) Disks (partitions), folders (directories) and files are organized in a treelike structure. There is a hierarchical order, starting from the root directory. Full sequence of directories leading to a given file is known as the access path. Computer Science EPM/03 20 20 Files and their organization (4) Computer Science EPM/03 21 21 Files and their organization (5) All this tree-like structure reflects only a virtual or logical structure of data. They are actually (physically) located on a disk (in the memory) in quite different order. Two main file systems used by PCs are: • FAT (File Allocation Table) used by MS-DOS and older versions of Windows, newer version used FAT32 (32 bytes, older 12 and 16). • NTFS (Windows NT File System), somewhat similar to HPFS (High Performance File System) by IBM. Used by all Windows systems from NT up. It allows big files, long filenames, access control, more tree levels, etc. Files are actually stored as a series of clusters. When file is removed, first – only its name is marked as „removed” and shifted to a directory known as a bin. When the bin is emptied, its filename is removed permanently from the system, while its contents is still present in the respective clusters. When some new information (file) is written over these clusters, recovery of the old files become more difficult, yet still possible. Computer Science EPM/03 22 This is the reason why so frequently hard disks containing sensitive information are sought by police and other security services. 22 Files and their organization (6) After some time of using a disk, the file storage becomes a nightmare: there are empty spaces, files are divided in many fragments stored in distant clusters, etc. One can even observe certain slowing down of the computer operation. It means that defragmentation is recommended. It may be executed by clicking the icon of the respective volume (disk or partition) with the right key of the mouse, then choosing properties and tools. There are three tools: • volume check (for physical errors) • volume backup • volume defragmentation. Computer Science EPM/03 23 23 Files and their organization (7) • volume check (for physical errors) • volume backup • volume defragmentation. If you wish flawless operation of your PC, you should perform regular checks and defragmentations. After starting the latter, the system tells you if the operation is really necessary. Running defragmentation you will ba able to observe how physical placement of the files on disk is changing (some files are unmovable – these are system files, which addresses on the disk are fixed. What regards making backup copies of the volumes, it is also highly recommended. These operations are appreciated in a moment your computer crashes down. Computer Science EPM/03 24 24 Files and their organization (8) Disk formatting is a serious operation, in which all the contents of the disk is erased and new sectors and clusters are formed. All the data are lost (special services can still recover at least part of them). Recently quite too frequently formatting becomes necessary. To avoid these troubles, partitioning of the hard disk is strongly recommended. Partitiong means dividing a physical disk into a number of volumes (partitions or virtual disks). First partition will maintain main symbol C:, while the next will be assigned with consecutive letters D:, E:, etc. OS is always located in C: partition and must be reinstalled from the original media after formatting. Also program files prefer being installed there. Your data, however, which means fruits of your work and efforts, should be stored in D:. Partitioning may be done using special programs like Partition Magic (and others). In a case of necessity of formatting, one must format only system partition (C:). Computer Science EPM/03 25 25 Files and their organization (9) In a case of necessity of formatting, one must format only system partition (C:). All programs must be reinstalled (no big deal, though time consuming operation for those who have legal programs) yet the data are not lost. One should remember to avoid storing one’s data in folders provided by the system (MyFiles, MyDocuments, MyPhotos, etc.) because these folders are always created in volume C:. Hence, they will be removed when formatting this volume. Most practical way is to have three partitions: C: main volume, containg the system and program files (large) D: data containing volume (large) E: mirror volume (small) – safety volume containing the mirror image of the former ones (compressed) Computer Science EPM/03 26 26 Booting sequence When a computer is switched on, we say it is booted or rebooted ... BIOS ROM (EPROM) Computer Science EPM/03 27 27 Computer viruses Computer viruses are small computer programs that can copy and distribute themselves without permission of the computer user. They can attach themselves to other files and be distributed with them worldwide using e-mail and internet system. One should not forget, though, spreading of viruses via external media (pen drives, CD or DVD). They can be divide into two main groups: • benign, once installed (also by themselves) they perform relatively innocent, practical jokes like drawing some pictures on the screen or writing some unjustified warnings. • malicious – these can do real harm like removing files from the storage devices, interfering with the OS, even formatting disks. Viruses usually infect the boot sector of the disk, to ensure that they will be run when the user boots the computer. Computer Science EPM/03 28 28 Computer viruses (2) A wider term is malware. Besides true viruses, it includes also worms, trojan horses, rootkits, spyware, adware (spam), even crimeware, and other malicious and unwanted software (worms and trojans differ from true viruses technically). Using suitable antivirus software is essential for secure and successful operation of your computer! One can observe slower operation of the system, though it is a price paid for the „civilization progress”. Computer Science EPM/03 29 29 Non-numerical information in digital computers (3) Graphics – semigraphics (using ready made blocks prepared as bitmaps). Character matrix (the example comes from old toy computers like ZX Spectrum or Commodore 64). Nowadays 12 bytes are used in height. It may be seen that 8 bytes defines the look (shape) of this character (ASCII code 97). There are programs known as font editors, permitting to define your own fonts by selecting the squares to be made black in the matrix. Computer Science EPM/03 30 30 Non-numerical information in digital computers (4) Complete screen is also a bitmap. Resolution is: 800×600 pixels (old), 1024×768 (most common SVGA), 1152×864, 1280×768 (good for movies), 1600×1200, 1792×1344. The number of bytes used in the screen memory (part of RAM reproducing the screen) depends also on the number of colors to be reproduced. Bitmap representation of graphics is also used in printers. Resolution here is indicated not by the pixels but by dots (essentially the same but the technical name is different) per inch: dpi. Typical resolutions are 150 dpi (poor), 300 dpi (standard), 600 dpi (good quality, I prepare drawings for my lectures in 600 dpi), 1200 dpi (very high quality). Say, „letter” format sheet (8,5×11 inch) printed as full page picture requires 300×300×8,5×11 (8415000) bits to be sent from the PC to the printer (B&W only). Computer Science EPM/03 31 31 Non-numerical information in digital computers (5) Bitmaps vs. Vector graphics pixels visible Computer Science EPM/03 32 32 Non-numerical information in digital computers (6) Bitmaps vs. Vector graphics Computer Science EPM/03 33 33