CS0.101 - Computer Programming | C Pro Lecture 1

with Prof. Suresh Purini
Sep 14, 2020 - Monday
Written by: Pratyaksh Gautam

The lecture recording

Computing system = Hardware + Software

Every computing system is composed of both hardware and software, for eg: applications (software) running on a smartphone (hardware). Computing systems can be run in parallel, through large networks of many computers, or they can also be run as a single computer. Our focus in this course will be on programming on a single computer.

Memory model

The memory is stored in this linear array form, where each memory cell has an address (for example 0x0, 0x1, 0x2, … ), and the memory controller allows the CPU to access individual bytes in the memory.

Execution model

Control instructions like branch allow us to jump back to a previous address.

For the sake of simplicity, let us assume that an instruction has a length of 4 bytes. Then, after an instruction is executed, the program counter increments by 4 bytes (the instruction length). The CPU itself only calls for the first address where the instruction begins. The memory controller then retrieves the whole instructions (4 bytes in our case) and then sends it to the CPU.

What is a program?

Simply put, a program is a sequence of instructions along with the necessary data.

The data can be:

Executing a program

  1. Initially, instructions and date of a program are present on the hard disk
  2. They are then loaded into the main memory.
  3. After this, control is transferred to the CPU to execute the program.

In the OS kernel, there is a ‘loader’ which performs this function of preparing the program to be run and transferring control to the CPU. So then who loads the loader? It is the job of BIOS (Basic Input/Output System), the first software to run when the computer is turned on. The BIOS loads up the bootloader, which in turn eventually loads the operating system. From then on the OS kernel handles such operations. The BIOS is stored on non-volatile flash memory, and is only used once (during startup), then the OS kernel takes over.