General Information (1)

  • An Operating System is actually a gigantic computer program. It controls the working environment of a computer.... The disk drives, the terminals, the memory and the CPU (Central Processing Unit) are all considered hardware and the operating system is software, i.e., a program.

  • The Operating System can handle many different tasks, e.g., file management, security, system resources allocation, etc., so it has many different components which are called system programs. Most of the system programs dwell on the disk drive because not al of them are used at the same time, thus, all modern operating systems are called "disk operating systems." One of the most popular ones, MSDOS, is the MicroSoft Disk Operating System.

  • The size of an operating system is proportional to how much work it has to perform. For personal computers, the system programs are smaller because there are less information to manage. For example, MSDOS requires less than 1 Megabyte of disk space but a mainframe operating system such as DEC's VMS system requires at least 23 Megabyte for the bare bone system. VMS is a multi-user system; it may deal with as many as 100 users.

  • The programs we use for word processing, balancing check books, or structural analysis, are called Application Programs. The operating system has the job of loading them into the system memory and activating them for your applications. On the PC, you type the program's name to activate a DOS-base application program; on the MacIntosh, you select a program in the window and click the mouse to activate the program; on VMS, you type "RUN SAP" to activate the structural analysis program SAP; finally, on UNIX, you just type the name of the program, just like MSDOS.

  • When a person asks you, "Do you want to go to lunch?" He should pause for a moment to wait for your answer....That would be considered a prompt. Each operating system has its own way of prompting you: MSDOS uses the > symbol to prompt you. On our school's unix systems, the prompt looks like "" with being the international name of the computer ALUDRA and (1) implies that it is the first prompt during a session.

  • UNIX file names have the convention of "name.ext," in which "name" is the name of the file to help identify its content. The "ext" is the extension of the file which identify what type of file it is. Common extensions used by UNIX users are: ".dat" for data files; ".f" or ".for" for FORTRAN source files; ".c" for C program source files; ".txt" for regular text files. Executable files usually do not have an extension in UNIX.

  • The UNIX command, cp file1.dat file2.dat copies the content of file1.dat to a new file file2.dat. If file2.dat exists before the "cp" command, it will be over-written.

  • The UNIX command, mv file1.dat file2.dat renames file1.dat to file2.dat. The letters, "mv," came actually from the word "move."

  • The UNIX command, rm file1.dat removes file1.dat from the system. It corresponds to the delete command of MSDOS and VMS systems.

  • The UNIX command, ls lists all the filenames in your current directory. ls -l will list more details about the files.

  • The above commands can help you manipulate files you already have, but to create a file, you must use an application program. In CE108, we use the screen editor, emacs because it will work on every computer system, from mainframes to personal computers. It is also a free software.

  • There are roughly 3 levels of application programs available for creating files: (1) editors, (2) word processing programs and (3) desktop publishing programs. "Editors" can help you create a plain text file. A word processing program can help you set the margins, manage fonts (bold faces, italic letters, etc), footnotes, justify paragraphs, etc. A desktop publishing program can put text, graphics and scanned images together for presentations. To write a computer program, an editor is sufficient and preferred.

  • At USC, the UNIX command, pine will activate the electronic mail utility.

  • To terminate your UNIX session, use the logout command.

  • The computer, even with the help of the operating system, cannot understand the programs we write. So we have another computer program, called a "compiler," to translate our programming language to machine languages.

General Information (2)

  • There are many different types of computer programming languages: some are called high-level languages and others are called low-level languages. Human languages are referred to as the highest level, so a high-level computer language is easier for us to learn than the low-level languages.

  • Pascal, FORTRAN, C, ADA, PL1, APL, COBOL, and BASIC are all high-level languages. C has some features of a low-level language.

  • Machine language is the lowest level language exterior to the CPU, it is coded in binary, e.g., 0011001010011101 for a 16-bit computer and a longer one for a 32-bit computer. Assembly language is the next lowest because there is a one-to-one correspondence between it and machine language. The advantage of assembly language is that it is verbal, e.g., MOV A,B or ADD A,5. These verbal statements can be converted to machine codes by a program called an "assembler."

  • Inside the CPU, there are micro-programs which controls the "gate sequences" of the transistor to perform the tasks the CPU was built to do.

  • The assembly language of each CPU is designed differently, so a program written in one assembly language (INTEL 80486) cannot be used with another processor (MOTOROLA 68040). Thus, the term "not portable" is used.

  • There is no one-to-one correspondence between a high-level language and machine language. In fact, all high-level languages have compound statements like, 3*(a+b)/c-6, but machine instructions can only deal with two operands at a time. To convert a high-level language into machine codes, we need a program called the "compiler."

  • To write a program in FORTRAN, you need a FORTRAN compiler.

  • To write a program in "C," you need a C compiler.

  • To write a program in BASIC, you need a BASIC interpreter. BASIC is designed to use as an operating system as well as a language interpreter. It was supposed to be used with cheap computers which came without an operating system. There are now very powerful BASIC compilers available.

  • Since machine languages and high-level languages are so different in nature, different compilers for the same language can interpret a program statement differently. An inefficient compiler can generate codes which runs many times slower than one written in assembly language.

  • Some people write the most frequently used "routines" in assembly language and put them in libraries. This way the high-level languages can access them as "canned functions." But you lose some portability with this method. To access these libraries, a "LINKER" is used to link all the pieces together after a program is compiled. At that time, all the pieces are already in machine codes.

  • To program in FORTRAN, you first type the program in a file program.f using an editor like EMACS. Then you can invoke the FORTRAN compiler and the linker using the UNIX command:
    f77 program.f -o fprog

  • To execute the program, just type fprog at the UNIX prompt, followed by enter

  • If you use the above UNIX command without the output option -o fprog then the name of the executable program is called a.out by default.

  • To program in C, you first type the program in a file program.c using an editor like EMACS. Then you can invoke the C compiler and the linker using the UNIX command:
    cc program.c -o cprog

  • To execute the program, just type cprog at the UNIX prompt, followed by enter

  • If you use the above UNIX command without the output option -o cprog then the name of the executable program is called a.out by default.

  • FORTRAN means FORmula TRANslation.

  • The inventors of C, feel a "simple" language should have a simple name, so they decided to use just one letter. Yes, there was a "B" language, used in-house at Bell Lab.

  • FORTRAN was invented back in the days of the 80-column computer cards, so you must be careful about which columns to use for a certain type of programming information.

  • Most of the newer languages prohibit the GO TO statements, therefore, no statement numbers are necessary and the program text can be written in free form. A statement is typically ended by a semicolon.

General Information (3 & 4)

  • While lawyers like to write documents of over 100 pages, engineers and scientists like to simplify documentation procedures. That's why the latter invented matrix notation, symbolic representations for summation and integration. Therefore, it is safe to assume that Fortran and C will not be like law notes, they would be more like mathematical representations: nice and concise.

  • C, Pascal, Lisp and many new computer languages are written in a "free-form," i.e., no restriction on which column to type the program. The lines are usually ended by a delimiter such as the semi-colon ; and program statements are not labeled.

  • Fortran and Basic are the older type of languages which have an outlined form for the program. For Fortran, columns 1 through 5 are reserved for statement labels (up to 5 digits 1 to 99999); column 6 is reserved for a continuation mark (if the previous line is too long, a mark such as $ or # will append the present line to the previous one); columns 7 through 72 are reserved for the program statements; finally, columns 73 through 80 are reserved for ordering the computer cards in case the rubber band is broken. For today's programming, columns 73-80 are useless. Some new compilers allow the use of 128 columns, but I would stay away from it so it could be considered a standard fortran program.

  • All processors (hardware) come with a set of machine instructions. They are combined into the following groups: The Arithmetic Group (add, subtract...); The Logical and Compare Group (and, or, xor...); The Jump Group (branching to other parts of the program conditionally or unconditionally); The Call and Return Group (same as the Jump Group except the return address is remembered); The Input/Output Group (interaction with peripheral devices through DMA or interrupt drivers).

  • Fortran is built like assembler language except it has powerful statements which can replace many (10, 50, 200) assembler language instructions in one line. Hence, it also allow the programmer to jump back and forth within the program using the powerful JUMP instructions, e.g., IF(I.GT.4)GO TO 45.

  • The new languages stress the "structured programming" concept, eliminating the JUMP group and relying on the CALL and RETURN group. Programs are organized "top-down" as the main program is divided into tasks and tasks are divided further into subtasks, and so on. Like a structure built with small blocks.... wow...

  • All the newer Fortran books have the title "Structured Fortran programming..." They sold fortran out... Fortran is for the free spirit... not programmers with hands tied behind their back... DOC's recommendation is to write a program which work... structured or not structured.

  • Structured programming has a lot advantages, it is also very beautiful. But sometimes it sacrifices efficiency, e.g., the president tells the vice president, the vice president tells the executive, the executive tells the project engineer, the project engineer tells the staff engineer, the staff engineer tells the technician, the technician tells the janitor that the president's bathroom needs more toilet paper. A beautiful example of structured delegation, but the paper might arrive too late.... after the board meeting.... The president should have used his structured programming book... the authors' page.

  • The variable names in C can be very long, like 23 characters. The variable name in standard fortran is 6 characters; some compilers will allow more, but 6 is the standard. The first character of the variable name must be a letter.

  • In C, every variable must be specified a "type" at the beginning of the program, otherwise, an error message will occur when the variable is referenced. In fortran, there are so called "default" variables, i.e., all variables starting with the letter A-H and O-Z are defaulted as "floating point" variables while those starting with the letters I-N are defaulted as "integer" variables. This convention is motivated by mathematics and is very convenient but if you misspell a variable name, the compiler will not report the error and all your answers may be wrong.

  • Arithmetic statements in C, Fortran, Basic, Pascal and many more are similar. The statement:
    should not be interpreted as a mathematical formula "a is equal to b plus c." It should be interpreted as "fetch b, fetch c, add, store a." Sounds like assembler language.... In fact it is perfectly okay in programming languages to write
    in mathematics, "a is equal to a plus 1.0" does not make sense. But in programming, it means "fetch the current value of the memory cell labeled "a," add 1.0 to it and then store the sum back into the memory cell labeled "a." Hence, the value of "a" after the instruction is 1.0 larger than the value before. The above arithmetic statement is written as "a:=a+1.0;" in Pascal, to emphasize the fact that the two sides are not equal.

  • The left side of the arithmetic statement should have just one variable name, the operation there is always "store" and erase past values. The right side of the arithmetic statement can contain many variable names and even function names separated by arithmetic operators such as +, - , * and /. The operation on these latter variables are always "fetch" and their values remain unchanged after the operation.

  • The algorithm for summing a group of objects is the same for all the computer languages, it goes something like
            initialize the variable sum to zero
            start the loop for summation
            obtain the object by calculation or through input
            perform the arithmetic statement sum=sum+object
            continue with the loop until a certain condition is met.

  • The algorithm for obtaining the product of a group of objects is the same for all the computer languages, it goes something like
            initialize the variable product to one
            start the loop for multiplication
            obtain the object by calculation or through input
            perform the arithmetic statement product=product*object
            continue with the loop until a certain condition is met.

General Information (5)

  • The UNIX command, mkdir namedir creates a subdirectory with a specified name namedir. The subdirectories in UNIX are similar to the concept of folders in Window systems. They are convenient for organizing files into categories.

  • After a subdirectory namedir has been created by the mkdir command, you can access it by using the UNIX command, chdir namedir or simply, cd namedir.

  • If you presently operating in the subdirectory namedir, you can reach the previous node of the directory "tree" by issuing the UNIX command, cd ..

  • You can remove the subdirectory namedir by issuing the UNIX command,
    rmdir namedir.

  • When you use the ls -l command, you can see the protection code of a given file or subdirectory in the form of rwxrwxrwx. The "r" will allow you to read the file, the "w" will allow you to overwrite or delete the file, while the "x" will allow you to execute the file. If one of those characters are removed, that function will become unabled. There are three sets of rwx values, the first set is applied to your account, the second set is applied to your group and the third set is applied to "world." The codes can be simplified by an octal code: 7 for rwx, 6 for rw_, 5 for r_x, 4 for r__, 3 for _wx, 2 for _w_, 1 for __x and 0 for ___. Some of the above codes are not practical. Generally, it is best to apply the code "755."

  • To change the protection code of a file to 755, use the UNIX command,
    chmod 755 filename

  • To change the protection code of a directory to 755, use the UNIX command, chmod 755 namedir

  • To allow a file to be copied between two USC accounts, be sure to change the protection of your user's account and that can be accomplished by issuning the UNIX command, chmod 755 ~