Some Review Material

Important metric time prefixes

When dealing with times in operating systems, it's important to know the difference between milliseconds, microseconds, and nanoseconds.

Each of the prefixes above is a factor of a 1000 away from the previous one. For instance, there are 1000 microseconds in a millisecond and 1000 nanoseconds in a microsecond. Most processors run at a clock speed of a few gigahertz. That means that means that they can do a few billion simple instructions, like adding integers, in a second. In other words, each of those instructions runs in a few tenths of a nanosecond. Most timing things we will be interested in with operating systems will happen at the microsecond or millisecond range.

Important metric size prefixes

Storage size is typically measured in bytes. Here are important metric prefixes for storage:

Each of the units above is a factor of a thousand greater than the previous. For instance, there are 1000 kilobytes in a megabyte and a 1000 megabytes in a gigabyte. In rare cases you may see even larger prefixes, specifically peta and exa, which are the next two after tera. These sometimes appear when talking about the amounts of data transferred over a busy network over a period of time.

CPUs

The central processing unit (CPU) is the key component of any computer. Without one, you really don't have much of a computer. Its job is to run instructions which are written in what's called machine language. Assembly language is a human-readable version of machine language. Most programs are written in a higher level programming language and compiled into machine language.**For some languages, like Python and Java, there is an intermediate program that sits in between. Below is a simple program written in the C programming language.

#include <stdio.h>
int main() {
    int x = 3;
    int y = 4;
    int z = x + y;
    printf("Sum is %d\n", z);
    return 0;
}

Here is the result of compiling it and running it through the Linux objdump command to spit out the machine and assembly language code. The machine and assembly language code shown here are for x86 processors. Different architectures have their own assembly and machine languages.

1139:       55                      push   rbp
113a:       48 89 e5                mov    rbp,rsp
113d:       48 83 ec 10             sub    rsp,0x10
1141:       c7 45 fc 03 00 00 00    mov    DWORD PTR [rbp-0x4],0x3
1148:       c7 45 f8 04 00 00 00    mov    DWORD PTR [rbp-0x8],0x4
114f:       8b 55 fc                mov    edx,DWORD PTR [rbp-0x4]
1152:       8b 45 f8                mov    eax,DWORD PTR [rbp-0x8]
1155:       01 d0                   add    eax,edx
1157:       89 45 f4                mov    DWORD PTR [rbp-0xc],eax
115a:       8b 45 f4                mov    eax,DWORD PTR [rbp-0xc]
115d:       89 c6                   mov    esi,eax
115f:       48 8d 05 9e 0e 00 00    lea    rax,[rip+0xe9e]        #
1166:       48 89 c7                mov    rdi,rax
1169:       b8 00 00 00 00          mov    eax,0x0
116e:       e8 bd fe ff ff          call   1030 <printf@plt>
1173:       b8 00 00 00 00          mov    eax,0x0
1178:       c9                      leave
1179:       c3                      ret
117a:       66 0f 1f 44 00 00       nop    WORD PTR [rax+rax*1+0x0]

The first column are line numbers. The middle column contains the machine language code. Note that it is a purely numeric language, shown here in hexadecimal. Each machine language command corresponds directly to an assembly language command shown in the right column. The instructions are things like mov (which moves a value into a register) and add (which adds two values and stores the result in a register).

Memory

Here is a little about types of memory on a system: