Very interesting first chapter reading:
- Text files : content in ASCII/Unicode
- Binary files : rest of them
Bits are nothing, only distinguishing factor is the context in which we view them.
Unix was written in C. C is small, efficient and successful.
- I turn you into her then turn you into him then turn you into 'it' and then you run.
src program (text)
pCAL: Preprocessor (.c,cpp,.i) -> compiler (.i,ccl,.s) "Note1" -> assembler[.s,as,.o] "Note2" -> linker[.o,ld,executable] "Note3"
Note1: Assembly Language is common o/p lang for diff compilers for diff HLLs.
Note2: Xlates asm lang into ML INSs and pkg them into a form - Relocatable Object Program
Note3: printf func resides in a precompiled obj file - printf.o this and other (libs) are merged together by Linker
HW Org:
Buses: Lane width = WORDSIZE (4 bytes)
I/O devices: I/O device is connected to I/O Bus by Controller or Adapter, chipset in device itself or on PCB(Mobo) and plugged into a slot on Mobo, respectively.
MM:DRAM
Processor(CPU): has PC(sto nxt ins), ALU(computes data/address), RX
Caches:SRAM
Catch the Cache:
A lot of data fetching, copying - speed up : use Caches.
Inc size, Dec access speed --->
CPU -> L1 -> L2 -> MM -> HDD -> NWSto
OS: Intf bw App Program and HW :: [App Progs] <->[OS]<-> [CPU,MM,IO]
Funcs: 1. Protect HW from misuse 2. Provide abstraction to Apps from diff low level HW devs
Abstractions:
A- Processor : Process
B- MM : Virtual Mem
C- I/O Devs : Files
:) Unix (Single) was named by K so to mock multiple complexities of "Multics"
POSIX STD : Std Intf for sys calls, shell progs, threads, N/W programming.
OS abs for running a program.
Gives program illusion that it owns CPU
OS achieves Concurrency by interleaved execution using Context Switch mech
Context = State(PC,RX,MM)
Disadv: Distorts notion of running time.
Threads: Multiple exec units of within a process. Ts run within the same process's context, share same code and global data.
Illusion that P has xclusive use of MM. Each P has same uniform view of memory, called Virtual Address Space. Top 1/4 reserved for [OS code + data] (Kernel) <restricted>, rest is for user program.
VAS has following segments: Lowest address to highest
- Program code and data =
Code (begins at same fixed addr)
Global data
- Heap
Xpands/Contracts as per malloc/free calls
- Shared Libs
Code and data for Libs
- Stack
Top of user VAS, compiler uses this stack to implement Function Calls
Grows/Shrinks as per Func call/return
Unix file is a seq of bytes. All I and O in system is done by R and W files, using OS's funcs called System Calls.
Most of the times we are just COPYING info
SYSTEM = HW + SW working together so that App Progs can run.