[CS:APP-ch1] A Tour of Computer Systems

CS:APP ch-1 A Tour of Computer Sytems

A computer system consists of hardware and systems software that work together to run application programs.

Tracing the life time of hello program.

#include <stdio.h>  
int main()  
        printf("hello world!\n");  
        return 0;  

1.1 Information Is Bits + Context

The hello program begins life as a source program ( a sequence of bits, organized in bytes )

Text files

  • files consist exclusively ASCII characters.

Binary files

  • all other files

All information in a system is represented as a bunch of bits.

The only thing that distinguishes different data objects is the context in which we view them.

1.2 Programs Are Translated by Other Programs into Different Forms

In order to run hello.c on the system, the individual C statements must be translated by other programs into a sequence of low-level machine-language instructions.

These instructions are then packaged in a form called an executable object program and stored as a binary disk file.

1.3 It Pays to Understand How Compilation Systems Work

Reasons why need to understand compilation systems

  • Optimizing program performance
  • Understanding link-time error
  • Avoiding security holes

1.4 Processors Read and Interpret Instructions Stored in Memory

To run the executable object file, type ./hello to an applcation program known as a shell

Hardware Organization of a System

  • Buses: transfer words
  • I/O Devices: system’s connection to the external world, connected to I/O bus by either a controller or an adapter
  • Main Memory: temporary storage device that holds both a program and the data it manipulates while the processor is executing the program
  • Processor: the engine that inter-prets (or executes ) instructions stored in main memory

Running hello

  • Reading command from keyboard
  • Load file from disk to memory
  • Write output string from memory to display

1.5 Caches Matter

The machine instruction in the hello program are originally stored on disk

When loaded, opied to main memory

When processor runs, copied into the processor ( register + caches )

deal with processor-memory gap

1.6 Storage Devices Form a Hierarchy

storage at one level serves as a cache for the next lower level

1.7 The Operating System Manages the Hardware


  • a layer of software interposed between the application program and the hardware
  • two primitive purpose: (1)protect hardware (2)provide applications with simple and uniform mechanisms for manipulating hardwares
  • achieve both goals via abstractions


  • The operating system’s abstraction for a running program
  • context switching


VIrtual Memory

  • Each process has the same uniform view of memory ( virtual address space )


  • A sequence of bytes, nothing more and nothing less
  • Every I/O devices is modeled as a file

1.8 Systems Communicate with Other Systems Using Networks

1.9 Important Themes

Amdahl’s law: observation of the effectiveness

Concurrency and Parallelism


  • a system with multiple, simultaneous activities


  • use of concurrency to make a system run faster

Parrallelism can be exploited at multiple( three ) levels of abstraction in a computer system. ( hight –> low )

  1. Thread-level Concurrency: multicore & hyperthreading
  2. Instruction-level Parallelism: pipeling
  3. Single-Instruction, Multiple-Data ( SIMD ) Parallelism

The Importance of Abstractions in Computer Systems

Processor side

  • instruction set architecture provides an abstraction of actual processor

Operating System side

  • Files as an abstraction of I/O
  • Virtual Memory as an abstraction of Program Memory
  • Processes as an abstraction of a Running Program
  • Virtual Machine as an abstraction of the Entire Computer