Computer Architecture, Compiling C Programs, and File Permissions

I. Basic Computer Organization
    A. Computer Architecture
	1. CPU: load instructions from memory and executes them
	    a. components of a CPU
	        i. ALU: performs arithmetic instructions on operands in the 
		    general registers
	        ii. Clock: controls the speed at which instructions are 
		    executed. One instruction is executed per clock cycle
	        iii. General Registers: holds operands on which instructions 
	        iv. Instruction Register: holds next instruction to be executed
	    b. instructions a CPU executes
		i. Memory: transfer data between memory and general registers
		ii. Arithmetic: perform arithmetic operations on operands
			in the general registers
		iii. Control: control which instruction is next loaded into
			the instruction register (e.g., if and loops)
		iv. System Calls: ask the OS to perform a task (e.g., print
			a value, read a value).
	2. Memory: contains both the instructions for a program and the data
		for a program
	3. Peripherals
	    a. Disk
	    b. Screen
	    c. Keyboard and mouse
	4. Network Interface
    B. Software
	1. Operating System: Coordinates the activity of the computer by
		controlling the activities of the CPU, memory, and peripherals.
	2. Program: A set of instructions and data that get loaded into 
		memory and direct the operation of the CPU.
	3. Executable: A program that has been compiled into a form recognizable
		by a CPU. Consists of 0s and 1s.

II. Compiling C Programs

    A. gcc: compiles a file into an executable called a.out
	Example: gcc hw.c

    B. gcc options
	1. -o filename: compiles a file into an executable named filename
	2. -c : compiles a file into an object file with a .o extension. 
	    a. The file has the same name as the original file. 
	    b. The file cannot be executed
	    c. The -c option allows files to be independently compiled. If your
		program consists of many different files, then when you change
		one file the -c option allows you to recompile only the changed
		file(s), rather than all the files in the program.

    C. Linking: The act of creating an executable from a set of object files.
	Linking is done by calling gcc with a list of .o files. For example:

	gcc -o printme callprintme.o printme.o
	1. Link Errors: If a procedure is used in one file but defined
		in another file, you must include all the .o files or gcc
		will give you an "undefined" procedure error. For example:

		gcc -o printme callprintme.o

		Undefined                       first referenced
		 symbol                             in file
		printme                             callprintme.o
		ld: fatal: Symbol referencing errors. No output written to printme

	    a. The problem is that printme is defined in printme.o but it is
		not included in the call to gcc.

III. File Permissions: Control who can see your files

    A. ls -l will print the file permissions for the files in a Unix directory

	1. Example: -rw-r--r--   1  plank  ...  1to10.c

	2. First four characters tell you what you can do

	    a. r means "read": you can read the file
	    b. w means "write": you can save the file
	    c. x means "execute": you can execute the file (i.e., the file
		is an executable)

	    Example: I can read/write 1to10.c but not execute it.

        3. Last three characters describe what others can do with this file.

	    Example: Others can r 1to10.c but not write or execute it

    B. chmod: allows you to change file protections