Skip to content

OSTEP - Intro

Posted on:May 27, 2024 at 07:13 AM

A program is set of instructions for the computer to execute, yes. I think we all agree on this. So, Running a program is as simple as IF, ID and EX (thanks to Von Nuemann). But who actually makes it easy? It is the operating system or OS.

Virtualization

You probably won’t want to forget this word and think it as important to you as it is for the OS. So it virtualizes physical stuff, only to be called a VM (lol).

Now, to better make use of this newly-formed VM, it supplies us with massive number of APIs generally, syscall (system calls), only to be called a “standard library”. But, even then it does it’s work diligently, being a resource manager, managing CPU, memory and disk.

cpu virtualization

…managing CPU.. hmm, being underused? virtualize it! in other words, bringeth oneself into thy delulu that it haveth infinite CPUs to run your Chrome, Android Studio, Cyberpunk and Inception all at once.

A little snip, I mean Spin(1); for you (does nothing just waits a sec and loops again), getpid() gets the PID (process id) for you (you can also kill it with kill [signal] PID), ez.

virtualizing memory

The foolery doesn’t stop here, now we begin to fool every program as if it has its own private memory (private virtual address space) mapped sophisticatedly onto the physical one by the OS.

concurrency

I can barely do multitasking, turns out our OS can also get overwhelmed sometimes due to these nasty POSIX or P-threads who share the same memory space as others and possibly multiple ones active at the same time.

persistence

The probability of you forgetting this piece even after reading it twice is quite high, unless we have privileged facilities like hard-drives, solid-state drives than just DRAMs for our brains. We also have a manager, namely, the filesystem, which does all the grunt work of polling to h/w devices and writing, reading and doing the stuff. Sometimes, something might go wrong or it might be just too much of a work to copy stuff, so filesystems follow a copy-on-write protocol. It’s like you keep a note of whom are you lending your stuff (it’s just a count, yet). Now, if someone wants to tinker with it, you lend a photocopy for further modifications now. If they just wanna read, it makes no sense to print it multiple times.

RAID : Redundant Array of Independent Disks

As the name suggests, it utilizes multiple hard-drives to store some data, to compensate for drive failing and stuff. It has data redundancy but can also contribute to performance gain by accessing/spreading the data across multiple hard drives. RAID 0, 1, 5, 6 are quite popular.

design

It is high time to realise, we almost take everything for granted; While playing your favourite childhood, did you ever think of the millions of lines of bare code written in C? or the instructions generated by our compiler or the machine code or those pretty \oplus gates? or the transistors; no. Abstraction, is what this is called, to make our work easy but at the same time ensuring performance, protection, isolation, reliability, energy-efficiency, security, mobility (add more good-sounding nouns here, global warming maybe? eh).

a brief history of time, err! OS

”Jobs” were processed in “batches” earlier as the old cabinets only used to run a single program at a time. Later, though they (OSes) were more than just libraries. A syscall raised by a h/w trap would transfer control to a trap handler and raise the privilege level to kernel mode, in other words, giving OS the full access to our h/w now. After it does its things, it can hand back control to us using a return-from-trap instruction and we resume our game.

mainframe > mini > personal

A cheaper, smaller alternative to mainframes, the mini. Also prospered, because now the OS could do multiple tasks and make better use of itself. The birth of PCSs paved its way out and has evolved a loooott. since then.

Did you know?

Android is also based on a modified Linux Kernel. macOS too, is in some way based off on the OG UNIX.