Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Choosing Hardware and an Operating System - Computational Physics | PHYS 4007, Study notes of Physics

Material Type: Notes; Professor: Luttermoser; Class: Computational Physics; Subject: Physics (PHYS); University: East Tennessee State University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/13/2009

koofers-user-59d-2
koofers-user-59d-2 🇺🇸

4

(2)

10 documents

1 / 37

Toggle sidebar

Related documents


Partial preview of the text

Download Choosing Hardware and an Operating System - Computational Physics | PHYS 4007 and more Study notes Physics in PDF only on Docsity! PHYS-4007/5007: Computational Physics Course Lecture Notes Section I Dr. Donald G. Luttermoser East Tennessee State University Version 4.1 Abstract These class notes are designed for use of the instructor and students of the course PHYS-4007/5007: Computational Physics taught by Dr. Donald Luttermoser at East Tennessee State University. Donald G. Luttermoser, ETSU I–3 i) The maximum and minimum size of a number is limited by the chip size. ii) The amount of precision possible for a number is also limited by the size (though some compilers are sophisticated enough to increase precision for a given chip beyond what the chip can normally provide). 4. Computers work with numbers (and any character for that mat- ter) in binary format: Two bits (= Binary digIT), 0 ≡ off and 1 ≡ on. a) There are 2N integers that can be represented with N bits. b) The sign of the integer is handled with the first bit (0 ≡ positive number), which leaves N −1 bits to represent the value of the integer. c) Therefore, N -bit integers will be in the range (absolute value-wise) of [0 : 2N−1]. i) Hence an 8-bit machine can handle integers in the range [–128 : 127]. ii) A 16-bit machine can handle integers in the range [–32,768 : 32,767]. iii) A 32-bit machine can handle integers in the range [–2,147,483,648 : 2,147,483,647]. iv) Finally, a 64-bit machine can handle integers in the range [−9.223372... × 1018 : 9.223372... × 1018]. Note I am using ‘real’ notation here due to the I–4 PHYS-4007/5007: Computational Physics large size of the number, on a computer, such a number would have no decimal point. Also note that in computer programming languages, numbers in scientific notation use the “E” (“D” for double precision – see below) notation: [–9.223372E18 : 9.223372E18]. v) Calculating (or expressing) integers that are smaller (if negative) or larger (if positive) than the given chip size would result in an underflow (negative) or overflow of the computer register (and typically crash one’s program) =⇒ the bigger the chip, the better it is for numerical work. d) Since binary strings of numbers are not easy for people to work with, a compiler is used to translate the binary numbers of the machine to either octal (base 8, instead of base 2), decimal (base 10, what we normally are used to), or hexadecimal (base 16 numbers). e) English letters and punctuation marks are processed on many computers as an 8-bit number called ASCII (Amer- ican Standard Code for Information Interchange) format (note that the first “sign” bit is not used in ASCII proto- col). Each character on the keyboard (including their cap- ital representations) has an ASCII-value associated with it ranging from 0 to 127 (e.g., ‘0’ (zero) has an ASCII value of 48, ‘A’ (capital-a) = 65, and ‘a’ = 97). Many of the ASCII code numbers between 0 and 127 are nonprint- able control characters. I will often refer to “text” files (in the Microsoft world), that is, those files that can be printed or viewed with an editor, as ‘ASCII’ files (as they are called in the VMS/Unix world). Donald G. Luttermoser, ETSU I–5 5. Numbers and character strings are stored on computers in words, where the word length is often expressed in bytes: 1 byte (1 B) ≡ 8 bits (8 b). (I-1) a) Conventionally, storage size is measured in bytes (or kilo- bytes [KB], megabytes [MB], and gigabytes [GB]). b) However, here “kilo” does not mean 1000, instead it is equal to 1 KB (1 K) = 210 bytes = 1024 bytes. (I-2) c) Confusingly, many machines measure their memory size in units of 1/2-kilobytes called blocks, or more precisely 512 B = 29 bytes = 512 bytes (I-3) (note that your textbook has a typo in it for Eq. (2.3) — ‘512K’ should read ‘512B’). d) As mentioned above for ASCII format, 1 byte is the amount of memory required to store a single character. This adds up to a typical typed page requiring ∼ 3 KB. 6. Data types on computers: There are two basic types of data that are operated on and stored by computers =⇒ integers and real numbers. Depending on the programming language one is using, there are various types of “integers” and “reals.” a) Integers are stored as I = sign × ( N−1∑ n=0 αn2 n), (I-4) where αn takes on either a ‘1’ value (the bit is set) or ‘0’ value (the bit is not set). For example, on an 8-bit I–8 PHYS-4007/5007: Computational Physics real fixed-point binary as 0 1001111 =⇒ (sign bit) × [ (1 × 23) + (0 × 22) +(0 × 21) + (1 × 20) + (1 × 2−1) + (1 × 2−2) +(1× 2−3) ] = 8 + 0 + 0 + 1 + 0.5 + 0.25 + 0.125 = 9.875 on an 8-bit machine. iii) All fixed-point real numbers have the same abso- lute error of 2−m−1 [the term left off the right-hand side of Eq. (I-5)]. iv) The correspondingly disadvantage is that small numbers (those which the first string of α values are zeros) have large relative errors. v) Relative errors tend to be more important than absolute errors (we will be covering errors in more detail later in the course), fixed-point real numbers are used mainly in special applications (like busi- ness). e) In scientific work, the programming language compilers (like Fortran) use floating-point numbers for reals (as such, reals are often referred to as ‘floats’ in some languages). i) In floating-point notation, the number x is stored as a sign, a mantissa, and an exponential field expfld. ii) The number is reconstituted as xfloat = (−1)s × mantissa × 2 (expfld – bias) . (I-6) Here the mantissa contains the significant figures of the number, s is the sign bit (still the first bit Donald G. Luttermoser, ETSU I–9 of the binary number), and the actual exponent of the number has a bias added to it. • Since we have a sign bit, the mantissa will always be positive. • The bias guarantees that the number stored as the exponent field is always positive (of course the actual exponent can be negative). • The use of the bias is rather indirect. For exam- ple, a single-precision 32-bit word may use 8-bits for the exponent in Eq. (I-6), and represent it as an integer. This 8-bit integer “exponent” has a range of [0:255]. Numbers with actual negative ex- ponents are represented by a bias equal to 127, a fixed number for a given machine. Consequently, the exponent has the range [-127:128] even though the value stored in the exponent in Eq. (I-6) is a positive number. • Of the remaining bits, one is use for the sign and the other 23 for the mantissa, where mantissa = (m1 × 2−1) + (m2 × 2−2) + · · ·+ (m23 × 2−23) , (I-7) with the mi stored liked the αi in Eq. (I-5). • As an example, the number 0.5 is stored as 0 0111 1111 1000 0000 0000 0000 0000 000 on a 32-bit machine, where the bias is 0111 11112 = 12710. I–10 PHYS-4007/5007: Computational Physics iii) Typically, the largest possible floating-point num- ber for a 32-bit machine is 0 1111 1111 1111 1111 1111 1111 1111 111 , which has the value 1 for all its bits (except the sign) and adds up to 2128 = 3.4 × 1038. Whereas the smallest possible floating-point number for a 32-bit machine is 0 0000 0000 1000 0000 0000 0000 0000 000 , which has the value 0 for almost all the bits and adds up to 2−128 = 2.9 × 10−39. As built in by the use of the bias, the smallest number possible to store is the inverse of the largest. f) Just as was the case for integers, reals come in a variety of “flavors” in various programming languages. For example: i) Single-Precision Real (sometimes called Floats or Real∗4 numbers): 32-bit = 4-byte word-size numbers, 6-7 decimal places of precision (1 part in 223), and a range = [1.17549435×10−38 : 3.40282347× 1038]. ii) Double-Precision Real (sometimes called just Double Precision or Real∗8 ): 64-bit (2 32-bit words → 11 bits used for the exponent, 1 for the sign, and 52 bits for the mantissa) = 8-byte word-size numbers, about 16 decimal places of precision (1 part in 252), and a range = [2.2250738585072014 × 10−308 : 1.7976931348623157 × 10308]. iii) Quad-Precision Real (Real ∗16 ): 128-bit (4 32-bit words → 15 bits used for the exponent, 1 Donald G. Luttermoser, ETSU I–13 from memory into cache is called latency. v) RAM: Random access memory or central mem- ory is in the middle memory hierarchy. This is where your program resides while it is being pro- cessed. The contents of RAM is lost upon comple- tion of the jobs (or the turning off of the machine). The RAM of your computer is analogous to the memory centers of your brain. vi) ROM: Read only memory contains data that is hard-coded on the chip (typically, non-erasable). Information on this chip tells the machine its iden- tity, senses the devices hooked to the motherboard (called peripherals), and tells the machine where to find the boot software. The ROM is analogous to your DNA. vii) Pages: Central memory is organized into pages, which are blocks of memory of fixed length. The operating system labels and organizes its memory pages much like we do with the pages of a book =⇒ they are numbered and kept track of in a table of contents. viii) Hard disk: Finally, at the bottom of the mem- ory hierarchy is the permanent storage on magnetic disks or optical devices. They are slow, but can store large amounts of data. The coding of the op- erating system, compilers, and any other documen- tation, whether in ASCII format or binary format is stored here. I–14 PHYS-4007/5007: Computational Physics ix) Backup devices: Since hard disks work very hard, they are the first thing that is likely to go bad on a computer. Once the head crashes on a disk drive, the data stored there is typically lost forever. As such, it is good practice to store the contents of your hard drive (i.e., hard disk) on a more per- manent and safe medium: magnetic tapes and CD-ROMs. x) Virtual memory: Virtual memory permits your program to use more pages of memory than will physically fit into RAM at one time. Pages not currently in use are stored in slower memory (typ- ically hard disks in a region called swap space) and brought into fast memory only when needed. The amount of memory space needed for a program to run is limited by the machine’s RAM plus the swap space size. In Unix, the amount of swap space available and total can be found with the “swap” (on some machines called “swapon”) command. 2. The speed of the CPU is determined by the clock chip that is attached to it. The faster the clock (measured in MHz or GHz), the faster your CPU. 3. CPU clock speed doesn’t tell the whole story in computer speed, the speed of the cache and the speed of the bus that talks to the hard disk (and other peripherals) is also important in “turn- around-time” in running a program. Donald G. Luttermoser, ETSU I–15 C. A Brief History of Operating Systems. 1. A simple definition of a operating system is the suite of programs that make the hardware usable. The operating system manages the CPU, disks, and I/O devices. 2. Manipulation of the operating system was typically one of the hardest aspects of learning to use computers which is why the “GUI (Graphic User Interface) mentality” has taken hold of the modern computers — the user no long needs to talk to the op- erating system, the GUI does it for you! (Which is actually a “pain-in-the-butt” if you need to actually talk to the operating system!) 3. We now follow the history of operating systems and programming languages that are important in the scientific community, starting in the 1940s: a) Early computers had no operating system (e.g., the IBM 604). b) The computer was told what to do with a low-level set of commands =⇒ assembly language. c) The IBM 604 could undertake 60 program steps before using punch cards as a backing store. d) Often, the user had to manipulate toggle switches to input the code for the mainframe. 4. The 1950s saw the advent and rapid changes in the capability of operating systems. a) Jobs were batched so that the time between jobs was min- imized. I–18 PHYS-4007/5007: Computational Physics PCs were replaced by 32-bit PCs during this decade. PCs started becoming very fast when the Intel Pentium chip was developed. b) DEC came out with a new 64-bit chip (the VAX chip is 32- bit) called the Alpha which gave rise to the AlphaStations. This chip required new versions of DEC’s OSs: VMS → OpenVMS, and Ultrix → OSF/1 (which later was renamed Digital Unix in 1998, then Tru64 Unix in 2000 when Compaq bought out DEC). c) Sun then came out with the Sparc-station (32-bit CPU) and a new OS called Solaris to run on it. d) This decade saw the last of the mainframes, as the work- station and PC explosion made this type of computing obsolete. Because of this, and the fact that their Alpha- Stations were not as popular as their VAXstations, DEC went “belly-up” at the end of this decade. e) Finally, this decade saw the emergence of a “free” version of Unix called Linux which was designed to run on PC-class machines. 9. In the 2000s, the bulk of computing is done by PCs. In the phys- ical science community, most of the number crunching is still performed on workstations, but many scientists are now switch- ing to PCs due their fast speeds and low costs. a) Sun came out with a new 64-bit chip and workstation called the Ultra stations. Their latest, and quickest work- station, is the multi-processor Blade computers. b) For workstations, the biggest sellers are Suns, Silicon Graph- Donald G. Luttermoser, ETSU I–19 ics, IBM Workstations, and HP Workstations. c) In 2002, Hewlett Packard bought Compaq and has an- nounced that they are dropping the AlphaStation from their line. This means the death of both Tru64 Unix and OpenVMS. d) In 2003, Apple came out with its 64-bit, dual processor, Power Mac G5, running Mac OS X which is a Unix-based operating system. e) In 2004, The Athlon 64 chip by Advanced Micro Devices (AMD) and the Intel Xeon 64-bit chip have appeared in PCs. These machines run either the 64-bit version of Mi- crosoft Windows XP or the 64-bit version of Linux. D. The Unix Operating System. 1. Since most of you are well aware of the workings on the various flavors of Microsoft’s OS (i.e., Windows), at this point, I will highlight the use of the Unix operating system since you will have to do a little work on one of the Department’s Linux computers in Brown Hall 260. a) Unix is the operating system of choice for number-crunching 64-bit RISC-based and CISC-based workstations, which are popular in the scientific community (astronomy and physics in particular) and in technical corporations. b) There are various flavors of Unix that exist on the market, each design for use by specific computer platforms. i) Solaris is the flavor of Unix that exist on Sun Mi- crosystems’ platforms (e.g., Sparc Stations and Ultra Station). You may also run across an earlier Sun operating system called the SunOS. This operating I–20 PHYS-4007/5007: Computational Physics system is no longer supported by Sun. ii) Irix is the version of Unix used on Silicon Graphics’ workstations. iii) HP/UX is the Unix flavor on Hewlett Packard’s RISC-based workstations. iv) Digital Equipment Corporation’s (DEC) version of Unix was called Tru64 Unix (previously known as Digital Unix, and previous to that, OSF/1) before they went out of business. v) There are at least two platform-independent ver- sions of Unix, SCO (Santa Cruz Operating system) Unix and BSD/OS (Berkeley Systems Development Operating System) Unix. vi) Mac OS X of Apple is based on the BSD version of Unix. vii) Finally, the Linux version of Unix is designed to run on a variety of different platforms from Intel microprocessors to Sun/Ultra and Alpha chip archi- tectures. Linux is one of the few versions of Unix that can be downloaded for free. 2. The History of Unix: a) Brian Kernighan and Dennis Ritchie both work at Bell Labs and were involved in the development of the Unix operating system and the C language. Donald G. Luttermoser, ETSU I–23 ii) Utility programs. c) Examples of shell are the Bourne shell (sh), C shell (csh), Bourne Again shell (bash), Korne shell (ksh), and the tcsh (tcsh). 2. Why use Unix? a) Unix is portable. b) Unix is a Multi-user Operating System. c) Unix is a Multi-tasking Operating System. d) Long running programs can be sent to batch which will run a process in background mode freeing up the terminal for coincidence interactive use. e) Users have the ability to write scripts to control the run- ning of complicated processes. f) Unix supports the X-Window protocol. X-Windows was ini- tially created by computer scientists from MIT to allow a windowing environment for multi-user operating systems such as Unix and VMS. 3. Getting Started in Unix. a) Unix is designed to be user-interactive — that is the user can ‘talk’ to the operating system directly through ter- minal windows. Much of the work you will do on the Linux workstation will involve use of such a terminal window. b) Users and passwords. The following commands are useful for checking on current users and changing your password: I–24 PHYS-4007/5007: Computational Physics Figure I–1: Directory Tree Structure of a Unix File System / (root) dev etc usr man man1 man2 man3 man4 lib bin users lutter atlas bin idl atlas hst mcmath iraf tex mwc jmo sbin passwd sets users password who allows you to see who else is logged on, showing the users on the system, their terminal ID numbers and when they logged in to the system whoami tells you your own username and when you logged in c) Getting Help: man Displays the online manual page for a command d) Other useful utilities are available through ‘pull-down’ menus on the X-Window ‘toolbar’ (e.g., Email, web browser, etc.). 4. Unix File System. a) The Unix file structure is a hierarchy with the root direc- tory ’/’ at the top (see Figure I-1). b) When you log in to a Unix system you are assigned to a login (home ) directory. For example: /users/lutter. Donald G. Luttermoser, ETSU I–25 c) The directory where you are working is your current direc- tory. The pathname of the file gives you the exact location of the file. The full path is the absolute pathname relative to the root directory. For example: /users/lutter/idl/mcmath is the directory where I might keep my observed spectra taken with the McMath Telescope. d) The relative path is the pathname relative to your cur- rent directory. For example: From the login directory /users/lutter the relative path is idl/mcmath. 5. File Basics and Filenames. a) Conventions. i) Filenames can be any length, and almost any char- acter is valid. Avoid the following: ∼ $ % & ( ) [ ] ’ ‘ ” ? \ ; < > + - | ! ii) Unix is case sensitive. iii) There is no division into filename and file ex- tension, although there are certain naming conven- tions. For example: *.c C language source code *.f Fortran 77 source code *.f90 Fortran 90 source code *.pro IDL source code *.tex TEX or LATEX source code iv) Wildcards can be used: ? represents any one character * represents any number of characters, including none I–28 PHYS-4007/5007: Computational Physics 7. Other Unix Commands and Tools. a) Displaying Contents of Files: cat concatenates and displays the contents of a file. The syntax of the command is: cat filename If the file is more than 24 lines the display will scroll off the screen. more displays output from file one screenful at a time. The syntax of command is: more filename b) Pipes and Redirection: The shell normally expects to re- ceive input commands from stdin (the keyboard). Out- put is normally sent to stdout (the screen) and any error messages to stderr (the screen). | pipe allows standard output from one command to be used as standard input for another command. For example: cat filename | more The output of the cat command is piped through the more command. > redirects stdout to a real file. For example: ls -l > filelist < redirects stdin to a real file. For example: newfile < filelist Redirection always sends output to a file, whereas pipe sends output to another command. There is no limit to the number of pipelines that can be set up. Donald G. Luttermoser, ETSU I–29 c) Searching for Strings: grep searches for text in either a single file or group of files. The syntax of the command is: grep “search string” filename grep -i ignores the case of the search string grep -l lists only the names of files containing the search string wc counts words and lines in files. The syntax of the command is: wc “options” filenames wc -c displays only the number of characters wc -l displays only the number of lines wc -w displays only the number of words i) grep searches one line at a time. ii) grep looks for strings of text and does not limit itself to whole words. iii) grep can be used with wildcards. d) File Permissions: i) The default setting for a new files is: - r w - - - - - - - which means that only the user can read and write a file. ii) The permissions column consists of ten charac- ters. The first character denotes the type of file. For example: - ordinary file d directory l link iii) The next three show access mode for the user (owner) of the file. I–30 PHYS-4007/5007: Computational Physics iv) The next three show the access for the group. v) The last three show access for all others. vi) The protection symbols mean: r read: allows user to read the contents of a file w write: allows user to modify a file x execute: allows user to execute or run a program file e) User Access: The different classes are defined as: u user (owner) of file g group file belongs to o other users a all users f) Changing Access Privileges: chmod changes the access mode of files you own, to restrict or allow access. The syntax of the command is: chmod “class(es)” “operation(s)” filename(s) “operation” is one of: + - = (to add, take away or set permissions). For example: chmod ug+w examplel F. Summary of Unix Commands 1. There are a large number of commands in the Unix operating system. Table I-2 lists some of the more common ones. 2. Note that with some of these commands, I have created new commands (using the alias command) that make a bit more user- friendly output of the original Unix commands. These new com- mands are listed in Table I-2 in column labeled DGL Com- mand. Note that the alias utility is only found in the csh, tcsh, bash, and Korne shells. (Initially, I have set all of you up on Donald G. Luttermoser, ETSU I–33 Table I–1: (continued) Unix DGL Command Description Command — Print a help file on the chmod command chmhelp Convert a dvi file file to a postscript file (one dvips file that can be printed on the laser printer) — Preview a dvi file on an X-Windows terminal xdvi file — Type a beginner’s reference guide to Unix help — Start IDL idl — Run the LATEX file file through the LATEX word latex file processor — Delete old (duplicate) versions of files pur c) Your can also suspend a foreground job by entering <Ctrl>– z (i.e., pressing down on the control (Ctrl) key when you hit the z key — note that this doesn’t work from inside an emacs process, <Ctrl>–z will save and exit the file you are editing). 4. Finally, we have only scratched the surface of Unix in this section of the notes. This, however, should be enough to enable you to work on the Linux workstation. G. The Emacs Editor. 1. Emacs is a user-friendly editor that exists on most Unix worksta- tions. a) Although emacs is not shipped with Unix itself, it is freely available to the Internet community. b) It was written (and still evolving) by the GNU Project, a group of computer scientists who don’t like the large amounts of money that vendors are charging for software — they write software and give it out for free! I–34 PHYS-4007/5007: Computational Physics 2. Unix’s standard editor is vi and it is very user-unfriendly — in- stead, use emacs! 3. To edit a file in the emacs editor, move to the subdirectory con- taining the file and enter emacs filename, where filename is the name of the file to be edited. 4. The Linux workstation has the most recent version of emacs on it which brings up a nice GUI widget. The buttons and pull-down menus are obvious in their operation, as such, we won’t describe the keyboard commands that one could also use inside of emacs. H. Additional Information about the Linux Workstation. 1. Most of you are not used to talking to the operating system by issuing commands at the system prompt in a terminal window (though you should practice getting used to it). a) Many Unix operating systems have a front-end window- ing system based on the X Window protocol called CDE (Common Desktop Environment). b) Most Linux operating systems (e.g., Red Hat) use the gnome front-end which is also based on X-Windows. c) As such, you can following the same protocol that you do on a Window’s machine by double clicking on icons and through the use of pop-up menus from the “toolbar” located at the bottom of the main console screen. 2. One final comment about using the Linux workstation (node: fes- ter): a) Since you can only log into this workstation from the con- sole in Brown Hall 260, you will have to develop a protocol Donald G. Luttermoser, ETSU I–35 for using the computer. b) Limit your time for each session to 1-hour per student per day. Feel free to go past this limit if there is no one waiting to use the machine. c) Let me know if you are having trouble getting time on the machine. If this happens, I set up a users schedule to allocate time. d) Another suggestion to avoid congestion on the worksta- tion is to write the first draft of your code(s) on a PC, then mail it to your ‘z-accounts’. You can then log into the mail server machine from the web browser software on fester and clip and past the text displayed on the web browser to an emacs window you can start from the Linux prompt (make sure the filename started with emacs matches what you are pasting from the web browser). 3. Also note that once you are supplied with a password to this machine, change it to something that is relatively cryptic (from the console) and remember your new password! If you forget your password, see me and I will issue you a new one. 4. Since the printers in Brown Hall 260 are not behaving well, I have set the default printer to be physlabprt3.etsu.edu in the lecture room (i.e., Brown Hall 264).
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved