Education

System programming

Lecture 0:

About the course. History of Unix, Linux. Architectures. Standards.

Version: 3

Vladislav Shpilevoy

vshpilevoi@mail.ru

  • 11 lectures
  • 1 mandatory exam
  • each is ~2-3h
  • 5 HWs
  • 1 HW - 15-25 points

About the course [1]

Marks:

  • 0-49 - 2 (D)
  • 50-69 - 3 (C)
  • 70-89 - 4 (B)
  • 90-inf - 5 (A)

About the course [2]

It was given at Moscow State University at CMC faculty as an optional course

Then it was translated to English by me while I worked at Ubisoft

Created as a part of the educational program of the biggest Russian IT company - VK Group

About the course [3]

System programming on the whole and in Linux especially

Covers basic themes such as Virtual Memory, File System and Devices, Processes, Multithreading ..., but down to every tiny detail, from userspace to hardware

Contains lots of examples, self-check questions, home tasks, and very detailed lecture notes

After the course you are supposed to actually know how your code works, down to the kernel and transistors.

Books:

  • "Linux Kernel Development" Third Edition, Robert Love
  • "Advanced Programming in the UNIX Environment" Second Edition, Richard Stevens

About the course [4]

Lecture plan

  • Your setup
  • History of Unix-like systems
  • Standards

What is needed? [1]

Any Linux or Mac

What to do with Windows? - Virtualbox option

Step one

Step two

Install Virtualbox

Download an ISO file with Ubuntu or with any other Linux

Step three

Install OS from the ISO file and enjoy Linux

What is needed? [2]

What to do with Windows? - WSL option

Run Powershell terminal.

wsl --install

Reboot with updates installation.

Run Powershell terminal again.

wsl --install -d Ubuntu

Run WSL app (find it in Windows search bar)

What is needed? [3]

Uniplexed Information and Computing Service

Dennis
Ritchie

Kenneth Thompson

Bell Labs

Unix

In 1969 Bell Labs abandones the project and creates Unix

Multics [1]

Multiplexed Information and Computing Service

1 - Unified process memory

Write

Write

Process memory

void *
mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);

Multics [2]

2 - Dynamic linking

Process memory

Multics [3]

.so, .dll, .dylib

PIC - Position Independent Code

mov edx, [ebp+8]

data[]

Data

Code

$> man gcc
-fpic
    ...
-fPIC
    ...

3 - Runtime changes of hardware configuration

Multics [4]

4 - Shell

v.shpilevoy$> echo 'hello world'

Multics [5]

5 - Security rings

Multics [6]

6 - Hierarchical file system

Multics [7]

Unix [1]

UNIX / eunuchs

Computer to run Multics

1969

Creation

1970

Name

1971

man

Unix [2]

1973

AT&T releases Unix System V

1977

Berkeley Software Distribution

1982

Rewritten in C

Unix [3]

Unix systems

Unix [4]

AT&T sells UNIX

Unix [5]

"Unix Wars"

Unix [6]

Linux [1]

Andrew

Tanenbaum

Linus

Torvalds

Kernel

Environment

Drivers, file system, virtual memory, ...

GUI, compiler, console, libraries, text editors

Linux

Linux [2]

"GNU is Not Unix"

Richard Stallman

Linux [3]

- Lets write some code, an adventure for a couple of years!

- ALMOST VERSION 1.0!

Torvalds UniX

TUX

Original

Linux Kernel Mailing List

 

http://vger.kernel.org

Linux [4]

"Tanenbaum–Torvalds debate"

Micro- and monolithic kernels

Microkernel [1]

IPC

Virtual Memory

Scheduler

Kernel address space

User address space

Keyboard driver

Sound

driver

<mute sound>

Messages through the kernel

Darwin

Mach

Unix

MacOS

iOS

watchOS

tvOS

#Mac
v.shpilevoy$ uname
Darwin

Microkernel [2]

Monolithic kernel

IPC

Virtual Memory

Scheduler

Keyboard driver

Sound

driver

<mute sound>

Call a function in the same process

Kernel address space

User address space

System calls

Standards [1]

Research Unix Release 7 50
4.4BSD 110
System V Release 4 120
Linux 3.2.0 380
FreeBSD 8.0 > 450
First Unix 6

System call count

Standards are for portability, compatibility

Uniform Draft Standard 1983

Berkeley Sockets

Standards [2]

Summary

Nothing is real "Unix" except an old really existing "Unix" system.

Linux, MacOS, Solaris, *BSD - all are slightly (more or less) different variations of kernels, which are Unix-like.

Kernels can be categorised as "monolithic" (one big process) and "micro" (many small processes).

There are standards. For example, both MacOS and Linux follow POSIX standard (like pthreads support). Following a standard means providing certain fixed API with a unified behaviour.

Conclusion

Next time:

The kernel. Structure. Process schedulers.


Press on the heart, if like the lecture

System programming 0

By Vladislav Shpilevoy

System programming 0

Linux vs Unix. Microkernel. FreeBSD, Ubuntu, Mac, System III, V, Unix time-sharing system, 4.4BSD. Standard: ISO C, POSIX, Single Unix Specifications. Organisations: Open Group, IEEE.

  • 2,780