🛗

Operating system

Resources

Foundations

NameTags
CS124 Operating Systems - California Institute of Technologycaltechcoursepintosslidesvideo
CS 162 Operating Systems and Systems Programming - University of California, Berkeleycoursevideo
Operating System Concepts, 10th edition. Abraham Silberschatz, Greg Gagne, Peter B. Galvin.bookhigh-level "concepts" bookthe dinosaur book
Understanding the Linux Kernel. Authors: Bovet and Cesati. Publisher: O’Reilly.booklower-level "implementation" book
Principles of Modern Operating Systems. José M. Garrido, Richard Schlesinger, Kenneth Hogansonbookjava implementation
Kernel Projects for Linux by Gary Nuttbookc languageit complements an OS theory booklaboratory manual of Linux internal exercises
The MINIX book. Operating systems Design and Implementation. Andrew S. Tanenbaum and Albert S. Woodlhullbalance between theory and practicec language
Tanenbaum, A. S., & Bos, H. (2014). Modern Operating Systems (4th ed.). Pearson.bookc languagetheory-focus
How to Make a Computer Operating Systemc++no proof-of-concept
Operating Systems: From 0 to 1assemblyc languageself-learner
6.828 Operating System Engineering MIT coursedialoguevideo
Operating Systems: Three Easy Pieces - University of Wisconsin, Madisonbookcourse
Operating Systems Development
The little book about OS development
Operating systems: principles and practice by Tom Anderson and Mike Dahlin
Writing a Simple Operating System — from Scratch by Nick Blundell, School of Computer Science, University of Birminghambookno proof-of-concept
CS 111: Operating Systems Principles by Stanfrod
CS 111: Operating System Principles by UCLA


Requisite

Introduction

What is an operating system?

👉🏼
An operating system is system software that manages the allocation and sharing of hardware resources that application programmers use as a standardized interface.

The operating system is the Computer land’s government.

Make up the operating systemDon’t make up the operating system
KernelUser interface. Although we see operating systems by user interfaces such as Graphical User Interfaces and Shells, they are not part of the operating system.
Bootloader, if the firmware is BIOS, but no UEFI.Compilers
Standard Interfaces such as POSIXEditors
Drivers
BIOS/UEFI

What do operating systems do?

Operating system tasks are managing processor, memory, device, storage, and providing an application interface.

Story

A brief story from the 1950s to the present.

Mainframes.

No operating systems?

https://www.youtube.com/watch?v=-rPPqm44xLs

https://www.youtube.com/watch?v=3rVfUbDsdf8

First operating system

The first industrial operating system released was GM-NAA I/O, sometimes called GMOS, of General Motors and North American Aviation for the IBM 704 computer in the May of 1956. Its purpose was batch processing.

However, the first operating system was released in 1953 for EDVAC.

Ryckman, George F. (April–June 1983). "17. The IBM 701 Computer at the General Motors Research Laboratories". Annals of the History of Computing. IEEE. 5 (2): 210–212. doi:10.1109/MAHC.1983.10026.

G. W. Reitwiesner, "The first operating system for the EDVAC," in IEEE Annals of the History of Computing, vol. 19, no. 1, pp. 55-59, Jan.-March 1997, doi: 10.1109/85.560738.

Batch processing systems

Batch processing systems are one that runs programs with no user interaction.

They are ongoing in scripts such as batch files (.ps) in Windows-based or bash files (.sh) in Unix-based. For instance, assuming a file with thousands of users, a possible need is to send emails to them every day at 6 am with an ad.

Notes

IBM Corporation. "What is batch processing?". zOS Concepts. Retrieved Oct 10, 2019.

Multiprogramming

Time-sharing

Multitasking

UNIX

Dennis Ritchie, Brian Kernighan, Ken Thompson, and others in Bell Labs released Unix in November of 1971.

Notes

Ritchie, Dennis, and Ken Thompson, “The UNIX Time-Sharing System,”, Communications of the ACM, 17,1 (July 1974), 1897-1920

Unix: A History and a Memoir. Brian Kernighan

Youtube Unix intro
The Evolution of the Unix Time-sharing System
, Dennis M. Ritchie, 1979.

Minicomputers

Multiprocessor systems

Virtualization

Emulation

Hypervisors

https://www.muylinux.com/2014/05/28/exirion-os-so-libre-mexico/

Specialized OS

https://developer.nvidia.com/drive/driveos

Today

💡
There is more life than Unix-like, Windows, or macOS. Some examples are IBM z/OS, VxWorks, and SpaceChain OS.

Some popular distros are Ubuntu, CentOs, Fedora, Debian, and Red Hat Enterprise Linux. By the way, I use Arch Linux.

Notes

Just for Fun. The Story of Accidental Revolutionary. Linux Torvalds and David Diamond.

TempleOs

Today

DeviceOperating system
Samsung Smart TVTizen —Linux-based [1]
Microsoft XBOX Xbox system software —Microsoft NT-based [2]
Nintendo SwitchHorizon [3]
Apple iPhoneiOS —Unix-like [4]
Sony PS5PlayStation 5 system software, BSD based. [6]
Huawei Mate 40 ProEMUI —Android-based [5]

[1] Samsung U.S. Newsroom, “Six Advantages of Tizen OS on Samsung Smart TVs,” Samsung US Newsroom, Jun. 15, 2021. [Online]. Available: https://news.samsung.com/us/six-advantages-of-tizen-os-on-samsung-smart-tvs/. [Accessed: Aug. 10, 2022]

[2] Trinder, Garry. "The Xbox Operating System". Xbox Engineering. MSDN. Archived from the original on November 2, 2018. Retrieved October 31, 2018.

[3] "Console Security - Switch". 30 December 2017. Retrieved 30 May 2018.

[4] Patel, N. (June 7, 2010). "iPhone OS 4 renamed iOS 4, launching June 21 with 1500 new features". Engadget.

[5] “EMUI 10.1 - HUAWEI Global,” Huawei.com, 2020. [Online]. Available: https://consumer.huawei.com/en/emui10-1/. [Accessed: Aug. 10, 2022]

[6] “PS5 System software (US),” Playstation.com, 2022. [Online]. Available: https://www.playstation.com/en-us/support/hardware/ps5/system-software/. [Accessed: Aug. 10, 2022]

Programming environment

https://wiki.osdev.org/How_kernel,_compiler,_and_C_library_work_together

API (Application Programming Interface)

“API” is a mechanism that enables two or more software components to communicate with each other with a specification hiding the internal details [1]. The simplest example of API is a client and server, where the server shows its headers, and the client calls them.

For instance, Amazon renders its amazon.com with Web APIs:

Web requests from your browser to Amazon servers.

[1] “What is an API? - API Beginner’s Guide - AWS,” Amazon Web Services, Inc., 2022. [Online]. Available: https://aws.amazon.com/what-is/api/. [Accessed: Aug. 10, 2022]

POSIX

POSIX is an API chiefly UNIX-like and it stands for Portable Operating System Interface.

IEEE Standard 1003.1

C++ https://www.iso.org/standard/79358.html

C https://www.iso.org/standard/74528.html

Doug McIlroy, Elliot Pinson, and Berk Tague described Unix philosophy as follows:

Windows systems

https://docs.microsoft.com/en-us/windows/win32/

Windows, POSIX equivalence

FORK, spawn …

Operating system

Operating System provides an API to processes, memory, filesystem, I/O devices, storage, network, users, and shell since it manages hardware resources.

For instance, printf in C, it’s provided by stdio.h-—UNIX headers to the standard I/O [2].

[2] Kernighan, Brian; Ritchie, Dennis M. (March 1988). The C Programming Language (2nd ed.). Englewood Cliffs, NJ: Prentice Hall. ISBN 0-13-110362-8.

The operating system zoo (Classification of Operating Systems)

Embedded operating systems

👉🏼
Embedded devices do not always have an operating system.

Real-time operating systems

Operating systems distinguish by their key parameters: time. In other words, they focus on doing tasks by a deadline. Examples are nuclear reactor systems, automobile manufacturing assembly line systems, military drone systems, or ballistic missile systems.

Instructional operating system and kernels

PINTOS

Pfaff, B., Romano, A., & Back, G. (2009). The pintos instructional operating system kernel. ACM SIGCSE Bulletin. Association for Computing Machinery. doi: 10.1145/1508865.1509023

"Xv6, a simple Unix-like teaching operating system". Retrieved 2014-09-22. Xv6 is a teaching operating system developed in the summer of 2006

MINIX

OS/161

System/161 2.x Software and Hardware Manual

David A. Holland, Ada T. Lim, and Margo I. Seltzer, A New Instructional Operating System. Proceedings of the 2002 ACM SIGCSE Conference on Computer Science Education, March 2002.

PDF

Research

https://dl.acm.org/sig/sigops

https://ieeexplore.ieee.org/search/searchresult.jsp?newsearch=true&contentType=periodicals&queryText=operating systems

https://cacm.acm.org/magazines/2022/5/260363-technical-perspective-what-is-the-ideal-operating-system/fulltext

Ecosystem

CISCO

RedHat

Jobs as Sysadmin,

X operating system contributor where X is Linux, Windows, Android, and so on.

HelpDesk

https://www.youtube.com/watch?v=v7fKfDp6cQs&ab_channel=PeladoNerd

How to learn operating systems?

  1. Understanding high levels concepts and using a real operating system.
  1. Implementing an operating system.
  1. Using an instructional operating system.

https://www.studytonight.com/tests/?subject=operating-system

FAQ

Why do we need operating systems?

Even though the operating system produces an overhead, it is necessary because it reduces development time in user applications and that is beneficial to final users.

What is the difference between GNU/Linux and Unix?

Although Dennis Ritchie considers Linux as the de facto Unix system (Interview with Dennis M. Ritchie Manuel Benet, LinuxFocus, July 1999) and the current Unix commercial versions and Linux are POSIX complain, they don’t have the same codebase, they extended that specification in a different way, and of course, they have a different license.

What do I call Operating System API?

Some interfaces are in libraries (for instance, stdio.h or unistd.h) and for others, you have to use exec stuff. So, you have got to search for your problem.

Worked example in Linux.

As user view (https://man7.org/linux/man-pages/man1/kill.1.html)

kill -KILL 3333

From programmer's view (https://man7.org/linux/man-pages/man2/kill.2.html)

#include <signal.h>

int main() {
    kill(3333, SIGKILL);
    return 0;
}

Some references are https://www.kernel.org/doc/man-pages/ and ‘The Linux Programming Interface’ (published in October 2010, No Starch Press, ISBN 978-1-59327-220-3).

Operating system development and its architecture. Design Considerations.

Common operating system components

Dreyfus, M. (2018). Debugging using strace - Mike Dreyfus - Medium. Medium. Retrieved from https://medium.com/@adminstoolbox/debugging-using-strace-efda7d65be1d

Operating system services

System calls are operations that the operating system makes for you.

Design Philosophy

Simple is beautiful sometimes called small-is-beautiful philosophy. Examples: Unix, Latin, RISC.

UNIX is done with only six basic system calls which are fork, executing another process, open, close, read, and write files.

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

Start off on complexity. Examples: Windows, Chinese, CISC.

Windows is done with every imaginable system call.

Operating system architectures. Operating system structures. Kernel models.

Monolithic systems

Layered systems

Microkernels

Client-Server Model

Virtual Machines

Exokernels

Modular Kernel

Low-level tools

Large Programming Projects

Vim, Make, C, GNU, Clang, GNU, C++,

Rust?

Instruction set architecture (ISA)

Because operating systems use low-level tools you as operating systems really have concerns about your ISA, but x86 is the most common so we are going to work with it. x86-32 and x86-64.

If you are an application programmer (including a compiler programmer), operating systems make a lot of work for your specification or requirements but they limited all work that you can in a computer.

Bootstrap process

Your programs and the kernel run on RAM, but who does load the kernel? Computers must implement a bootstrap process to load the operating system. But your computer needs Firmware which is software that is in persistent memory —it lives after your computer shut down. LILO and GRUP are bootloaders.

Bootstrapping (or booting) is the process to pass the control into software instead of raw hardware. The bootloader is the software that follows the CPU vendor protocol to be able to use machine resources and it is loaded by the firmware in the ROM (UEFI or BIOS). Developing that firmware is a vendor task, and developing the bootloader is an operating system’s developer task. The firmware is a de facto standard, so you must read the vendor manual. Remember, a lesson is “follow the standards”.

Modern computers use read-only memory (ROM) to load the kernel. EPROM and EEPROM are electric-erasable versions.

Every processor implements an instruction set (ISA), and the processor in their manuals specify what are the way to bootstrap a program —normally the kernel, but, you can run other programs. Today the most common ISA for general-purpose computers are IA32 and x86-64. For our purposes, Intel and AMD sets are identical.

For illustrations, we are focusing on general-purpose computers with IA32, but the general idea the following the protocol by specification is the same for other processor.

“Plug-and-play” is an auto-discovery mechanism where the hardware bus protocol must be updated to identify and initialize devices where the OS Kernel had to prove various IO ports. Plug-and-play buses are PCI family, USB, FireWire, PC Carc/PCMCIA.

BIOS or UEFI are special firmware that lives in the ROM and whose main mission is loading the bootloader.

BIOS is the original firmware for x86 computers, it provides some basic operations like screen output. The ultimate goal of OS is to get into protected mode.

Advanced Configuration and Power Interface (ACPI) is a standard that defines a platform-independent interface for hardware configuration. It ables you to plug-and-play and power management. As an OS kernel, ACPI consists of tables that contain platform configuration details that are accessible through a structure called the Root System Description Pointer. APIC details.

Unified Extensible Firmware Interface (UEFI) is a standard that has more capabilities than previous firmware. Unlike BIOS which works with Master Boot Records, UEFI works with GUID Partition Tables (GPT). Those features are a modular system, writing Unicode symbols, multi-multiboot services, and backward compatibility with BIOS. Some people see as drawbacks that the main driver is Microsoft and its “secure boot feature”. Vendors are migrating to UEFI, even though UEFI is large, complex, and has bugs.

You can check out a IA32 bootstrap with BIOS in ROM as follows

  1. Someone or something starts the motherboard.
  1. A circuit reset the IA32 processor.
  1. IA32 processor starts executing instructions at 0xFFFFFFF0 immediately after a reset.
  1. Computer manufacturers place a ROM in this address range to start the boot process. IA32 CPUs start off in ring 0 (kernel modes). It runs the BIOS.
  1. BIOS runs some diagnostics on the hardware which is the Power-on Self Test, a.k.a. POST. It loads your bootloader in 0x7C00 address, you have a boot sector in only 512 bytes to load the next stage.
  1. Bootloader. Here is when you go from the old archaic modes x86 or 8088 memory addressing modes into the real model. Disk partitions. Here you load the kernel. The bootloader can interact with the firmware but it is not in protected mode, which means you can interact with basic device drivers (keyboard and screen) but is not safe. When you pass to kernel, you cannot do anymore.
  1. The kernel does some bootstrapping operations such as disk partitioning (MBR or GPT), memory virtual management settings, and others. Now kernel is responsible to interact with Device drivers and interrupts. Plug and Play come up by ACPI Standard.
  1. The kernel starts the virtualization —Process management and memory management.
  1. Happy user!

Firmware

Today, firmware can be BIOS or UEFI. If your firmware is BIOS, you have to write your bootloader, but you don’t on UEFI, because it has a bootloader manager called bcfg. UEFI has more benefits than a program that aims to load the kernel. Both you have got implement GDT, IDT, and so on.

UEFIBIOS
Standard.Legacy.
UEFI leaves you in protected mode (long mode if your ISA is 64 bits, …)You have to make an assembly code in order to move from real mode to protected mode
Things are nonstandards but historical reasons work.

Notes and references

interrupts

IRQ

Programmable Interrupt Controller (PIC)

Real Mode

Protected mode

https://www.youtube.com/watch?v=ejz7lNN5XG4&ab_channel=GunnarWolf

https://wiki.osdev.org/Interrupts

https://arjunsreedharan.org/post/99370248137/kernels-201-lets-write-a-kernel-with-keyboard

Mastering Embedded Linux Programming

https://wiki.osdev.org/BOOTBOOT

https://www.codeproject.com/Articles/664165/Writing-a-boot-loader-in-Assembly-and-C-Part

https://en.wikibooks.org/wiki/X86_Assembly/Bootloaders

https://wiki.osdev.org/Rolling_Your_Own_Bootloader

https://www.codejam.info/2021/08/super-fast-boot-linux-efistub.html

https://wiki.archlinux.org/title/Arch_boot_process

https://www.rodsbooks.com/efi-bootloaders/

https://wiki.osdev.org/UEFI

https://interrupt.memfault.com/blog/zero-to-main-1

https://developer.ibm.com/articles/l-linuxboot/

https://wiki.osdev.org/UEFI

https://stackoverflow.com/questions/58002542/how-does-uefi-boot-mode-boot-flows

"Beyond BIOS" book

https://github.com/torvalds/linux/blob/master/arch/x86/boot/main.c

Process management

💡
The operating system virtualizes your programs. It means your program don’t worry about other process and memory.
https://twitter.com/lauriewired/status/1677082589507784704/photo/1

Process description

A process is an instance of a program in execution.

A program from an operating system’s view is a bunch of isolated instructions on the disk.

Process data structures

Global Descriptor Table

ACPI MADT table

ELF

Machine state

Create

Destroy

Wait

Status

Process API

fork, exec, process tree, spawn

Direct Execution

Scheduling

The scheduling problem is hard.

CPU Scheduling

Ostrich algorithm?

Goals

Concepts

Algorithms for batch processing

Arrival Time

Completion time

Burst time

Turn Around time

Waiting Time (W.T.).

First come, First served (FCFS)

Shortest-Job-Next

Priority Scheduling

Shortest Reaming Time

Expropiative version

Round Robin

Expropiative version

Quantum

Multiple-Level Queues Scheduling

Summarize

https://docs.google.com/spreadsheets/d/1SBEBDR7Lux3Xo-Jac3bKvISdmSSQdnNkYpb8zOeKKYI/edit?usp=sharing

Algorithms

CPU Scheduling – Jerry Breecher

Notes

https://www.tutorialspoint.com/operating_system/os_process_scheduling_algorithms.htm

http://perugini.cps.udayton.edu/teaching/courses/cps346/lecture_notes/scheduling.html

https://www.geeksforgeeks.org/program-fcfs-scheduling-set-1/

http://laurel.datsi.fi.upm.es/_media/docencia/asignaturas/dso/planificacion_2010_4pp.pdf

http://perugini.cps.udayton.edu/teaching/courses/cps346/lecture_notes/scheduling.html

http://www2.latech.edu/~box/os/ch05.pdf

https://cryptomex.org/SlidesSistOp/AdmonProcs.pdf

💡
kill -l list some possible states

Segmentation. Stack-based memory allocation.

💡
The operating system assigns a RAM Layout to your programs.

https://stackoverflow.com/questions/45303014/explanation-of-all-columns-in-size-command-output

Inter-process communication (IPC) models

It depends on what OSI model we are.

Message-passing

Example include , , .

Shared Memory or Shared-state

Example include and .

Note. Making a child i.e. fork() doesn’t mean sharing memory.

Inter-process communication (IPC) strategies

Interrupts & Signals

Interrupts, sometimes called traps, are

References

harismuneer. (2022, September 30). BelalHashmi-Assembly-Exercise-Solutions. Retrieved from https://github.com/harismuneer/BelalHashmi-Assembly-Exercise-Solutions

https://www.youtube.com/watch?v=54BrU82ANww&ab_channel=Computerphile

Microprocessor Design/Interrupts - Wikibooks, open books for an open world. (2022, September 16). Retrieved from https://en.wikibooks.org/wiki/Microprocessor_Design/Interrupts

x86 Assembly/Advanced Interrupts - Wikibooks, open books for an open world. (2022, September 16). Retrieved from https://en.wikibooks.org/wiki/X86_Assembly/Advanced_Interrupts

5.-IRQs and the PIT. (2017, January 15). Retrieved from http://www.jamesmolloy.co.uk/tutorial_html/5.-IRQs and the PIT.html

Interrupt Service Routine -Keyboard Interrupt Example | Hitch Hiker's Guide to Learning. (2022, September 30). Retrieved from https://www.hitchhikersguidetolearning.com/2021/05/09/interrupt-service-routine-keyboard-interrupt

Shared memory systems

Queue passing

Pipes

CS 241 - System Programming (2019, October 05). CS 241 | Computer Science | UIUC. Retrieved from https://cs.illinois.edu/academics/courses/cs241-120201 https://courses.engr.illinois.edu/cs241/sp2014/lecture/28-IPC.pdf

User mode

Example

ls | grep .c | wc -l

It means

stdin → ls → grep .c → wc -l → stdout

Programming mode

Named pipes

Worked example

  1. Communicate two processes made in two different programming languages by pipes.
  1. A starvation-free job-scheduling policy guarantees that no job waits indefinitely for service. Which job-scheduling policies is starvation-free? Why?

References

Johnny Huang » Linux IPC with Pipes. (2015, August 08). Retrieved from https://hzqtc.github.io/2012/07/linux-ipc-with-pipes.html

Sockets

“Socket” is a generalized interprocess communication that can exchange data between applications in a network.

Application Protocols are above sockets such as RPC (remote procedure calls), HTTP, FTP, REST, WebSocket …

Case study.

References and notes

https://en.wikipedia.org/wiki/Inter-process_communication

Worked examples

References

Chapter 7 Abraham Silberschatz Operating System Concepts 9th

Notes and references

https://www.cs.cmu.edu/~ralf/files.html

FAQ

Concurrency & Parallelism

💡
The operating system itself was the first concurrent program.

“Concurrency” is a computing model (language concept) where a system executes nn computations during overlapping time periods at most nn (<n< n) processors and over on memory.

“Parallelism” is a computing model (hardware concept) where a system executes nn computations during overlapping time periods of at least nn (n\ge n) processors and over on memory.

Multiprogramming refers to concurrency and parallelism, informally multiprogramming is a situation where you cannot say which event will happen first by looking at the program.

Time slicing.

Scheduler.

Examples of the systems that deal with multiprogramming are

Competitive and Independent concurrency is the event where two or more concurrent subsystems do not communicate with each other nor sync with each other neither. You don't worry about how to share the subsystem states and sync processes.

gantt
    title Competitive and Independent concurrency
    dateFormat m mm
    section Process are independent
    Process A           :a1, 0
    Process B           :a1, 0

Cooperative concurrency is the event where two or more concurrent subsystems communicate or sync with each other. You worry about and .

References

Reading 21: Concurrency. (2022, May 23). Retrieved from https://web.mit.edu/6.031/www/sp22/classes/21-concurrency

https://www.info.ucl.ac.be/~pvr/VanRoyChapter.pdf section 4.3 page 25

Classic problems

Reader & Writer

Race condition

A race condition or race hazard is the condition of a system where the system’s substantive behavior is dependent.

Non-determinism or Indeterminate.

Generally speaking, multiprogramming is a non-determinism situation.

Suppose two concurrent tasks:

print("yes")
print("no")

Because tasks run concurrently, the order of execution depends on the scheduler. So the output might be “yes no” o “no yes”.

Heisenbugs

Threads

While the processes are isolated, threads share the same data (). So, if you want multi lightweight tasks or need to share data easily with each other, a sound choice is to write a multithreaded process.

A thread is a flow of execution of a process. It said that a process is sequential when it only has a thread and if it has multiple execution flows is known as multi-threaded. The main thread is a special one because it is the entry and exit point of a process.

The threads are in the user-level, kernel-level threads, and lightweight threads. In the Linux case, a lightweight process and a kernel-level thread are the same but from a different stand of point, the former from the Kernel case, the latter from the user space.

Tasks.

Models.

"What are Linux Processes, Threads, Light Weight Processes, and Process State." 27 Feb. 2023, www.thegeekstuff.com/2013/11/linux-process-and-threads.

"Process - (Kernel) Thread (Lightweight processes - LWP)." Datacadamia - Data and Co, 5 Apr. 2020, datacadamia.com/os/process/thread.

Lightweight processes.

An introduction to programming with threads, Andrew Birrell, Research Report 35, Digital Equipment Corporation Systems Research Center, 1989.

Why not? The Problem with Threads, Edward A. Lee, UC Berkeley, 2006

Synchronization

In computer systems, synchronization is the relationship between events. We have seen problems if the events were free, so your system has to deal with two constraints:

Producer and consumer.

Serialization.

Mutual exclusion.

Spurious wakeup

Piece of advice for making safe Synchronization

Dining Philosophers

Mechanisms for Synchronization

Mutual exclusion

Locks

Critical section

Thread Safety

Interrupts & Signals

Promises

Semaphores

Monitor Brinch Hansen (1973), Hoare (1974)

Monitors

Actor model

Dekker’s algorithm

Peterson's algorithm

Remove Method Invocation (RPC)

CORBA Web Services

J2EE

COM/DCOM

Websocket

Banker’s algorithm

References

The Little Book of Semaphores, Allen B. Downey.

FAQ

What is the difference between fork and thread?

Memory management

Background

Memory addressing

Heap

Dynamic Relocation

Static Relocation

MMU (memory management unit)

Protection

Sharing

Base

Worked examples

Continuous Memory Allocation

Paging

Structure of the Page Table

Swapping

Virtual Memory

ZRAM

Debugging

Valgrind Home. (2022, November 14). Retrieved from https://valgrind.org

References

Memory Management

Storage management. File systems. Persistence.

File system

Partitioning Table GPT/MBR

FUSE

https://wiki.archlinux.org/title/Solid_state_drive

https://www.youtube.com/watch?v=P-9osuSdGGI&ab_channel=SpaceRex

Potpourri. (2022, October 27). Retrieved from https://missing.csail.mit.edu/2020/potpourri

https://en.wikipedia.org/wiki/List_of_file_systems

Input/Output device management

Text rendering

VGA text mode

Interruptions and traps

Interrupt descriptor table

Keyboard & Mouse

Graphics

No.

Windows managers and compositors

Assignment

References

[Intel (2011)] Intel 64 and IA-32 Architectures Software Developer’s Manual, Com- bined Volumes: 1, 2A, 2B, 3A and 3B. Intel Corporation (2011).

Virtualization

Virtualization is a mechanism that provides access transparency to the operating system, networks, storage, processes or physical machines. Depending on the lower layer and what it offers to the upper layers, we can classify virtualization.

Emulators

An emulator mimics an instruction set architecture at behavior over a host architecture.

DosBox

https://www.isardvdi.com/

API Emulator

An API emulator mimics the behavior of one operating system on another. Therefore, these emulators implement the methods of the guest system based on the host kernel. For example, WINE re-implements the Win32 API, and WSL has re-implemented POSIX.

Virtual machines

Architecture

Hypervisors

A hypervisor is a software component that manages virtual machines. There are two main types: bare-metal hypervisors (also known as type 1) and software-based hypervisors (also known as type 2).

Virtual Box

VMware

QEMU

libvirt

KVM

Clients

Vagrant

Cookbook with QEMU, libvirt and KVM

Storage virtualization

Network virtualization

Data virtualization

Application virtualization

Application virtualization is a technology that allows you to run software applications in isolated environments, separate from the underlying operating system and other applications on a computer.

Package managers

NixOS

Bundle managers

Flatpack

Snap

X2Go

Containers

Docker

LXC

Podman

Kubernetes and Docker Swarm

WSL

VNC, RDP and ssh -X

NoVNC

https://www.nomachine.com/

Wayland Westorn

Guacamole

NoVNC

https://github.com/sanchezcarlosjr/desktop-app-to-webapp

Rootless

https://github.com/fsquillace/junest

References

Mastering KVM Virtualization by Vedran Dakic, Humble Devassy Chirammal, Prasad Mukhedkar, Anil Vettathu

https://www.docker.com/blog/app-virtualization-docker/

https://aws.amazon.com/what-is/virtualization/

https://www.youtube.com/watch?v=WhENXFkiOlI

Linux

Bresnahan, C., & Blum, R. (2019). CompTIA Linux+ Study Guide:
Exam XK0-004. Sybex, a Wiley brand.
Bresnahan, C., & Blum, R. (2020). Lpic-1 - Linux Professional
Institute Certification Study Guide: Exam 101-500 and exam
102-500. Sybex.
Brunson, R., & Walberg, S. (2016). CompTIA Linux+ / Lpic-1 Cert
Guide. Pearson Certification. [Clásica]
Inshanally, P. (2018). CompTIA linux+ certification guide. Packt
Publishing.
Jordan, T., & Strohmayer, S. (2020). CompTIA linux+ certification
all-in-one exam guide: Exam XK0-004. McGraw-Hill.

Serna, M. y Allende, S. (2020). Sistemas operativos: Linux.
Jorge Sarmiento Editor - Universitas. Recuperado de:

https://elibro.net/es/ereader/uabc/175148?page=1

Linux as user

Unix philosophy

https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/

Shell scripting

Morris, J., McCubbin, C., & Page, R. (2018). Hands-on Data Science with command line: Automate Everyday Data Science tasks using command line tools. PACKT Publishing Limited

Janssens, J., & O'Reilly, T. (2021). Data Science at the command line: Obtain, scrub, explore, and model data with Unix Power Tools. Recuperado de: https://datascienceatthecommandline.com/2e/index.html
Pelz, O. (2018). Fundamentals of linux: Explore the essentials
of the Linux Command Line. Packt Publishing.

Basics | Cheat sheets | Linux Command Library. (2023, January 07). Retrieved from https://linuxcommandlibrary.com

Command-line Environment. (2022, October 27). Retrieved from https://missing.csail.mit.edu/2020/command-line

pv

dialog

textual

rich

dialog --title "Input Box" --inputbox "Input" 0 0 2>output.txt

Dotfiles

dotly

Syscalls

Wang, K. C. (2018). Systems programming in Unix/linux.
Recuperado de:
https://link.springer.com/book/10.1007%2F978-3-319-
92429-8#about

strace

Process

systemd

Kernel Modules

You’re going to write a kernel module in Linux, so you must be careful since an error could crash your system. You can build a safe environment with docker.

docker run --volume "$(pwd):/temp" -it --rm archlinux /bin/bash
Docker environment

You can list all kernel modules using

lsmod
Module, Size (bytes), Process

If you are interested in kernel modules, read [1]. Essentially you need to install

pacman -S gcc kmod linux-headers make

You can hello world file in

References

[1] The Linux Kernel Module Programming Guide. (2022, December 25). Retrieved from https://sysprog21.github.io/lkmpg/#introduction

Suspend a process and resume it later

How can I resume a stopped job in Linux? (2022, December 31). Retrieved from https://superuser.com/questions/268230/how-can-i-resume-a-stopped-job-in-linux

sk. (2022). How To Suspend A Process And Resume It Later In Linux - OSTechNix. OSTechNix. Retrieved from https://ostechnix.com/suspend-process-resume-later-linux

Daemons

Systemd

Parallel process

prog1 & prog2 &

https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script

Background process

# ctrl+z
bg # last program to background

make &

nohup

nohup --help

User commands

Interlude

https://missing.csail.mit.edu/2020/potpourri/

IPC

Interlude

Pipes

Interlude

Queue Messaging

ipcrm -q

Interlude

Shared Memory

Interlude

Sockets in POSIX

Socket system call

socket(domain, type, protocol) is a system call that creates a new socket where domain={AF_UNIX, AF_INET, AF_INET6, …}, type={SOCK_STREAM, SOCK_DATAGRAM, …}, listen=0.

Some Socket Domains. It is also known as the “Address families”.

Domain.
Address family
(AF_* constant)
sa_family_t
Where perform communication?Which hosts are connected?Address structure
AF_UNIXKernellocalhost

struct sockaddr_un {
sa_family_t sun_family;
char sun_path[108];
}

where

sun_family is “AF_UNIX”,

sun_path is the pathname to a plain text file.
We recommend locating your files on/tmp/


References
unix(7) - Linux manual page. (2022, September 26). Retrieved from
https://man7.org/linux/man-pages/man7/unix.7.html
AF_INET

It is a communication
IPv4on hosts connected by IPv4struct in_addr {
in_addr_t s_addr;
};

struct sockaddr_in {
sa_family_t sin_family;
in_port_t sin_port;
struct in_addr sin_addr;
unsigned char __pad[X];
};


where

s_addr is the IPv4 address,

sin_family is “AF_INET”,

sin_port is the port number from 1 to 65,535,

__pad[X] is the pad to size of ‘sockaddr’ structure
AF_INET6IPv6on hosts connected by IPv6struct in6_addr {
uint8_t s6_addr[16];
};

struct sockaddr_in6 {
sa_family_t sin6_family;
in_port_t sin6_port;
uint32_t sin6_flowinfo;
struct in6_addr sin6_addr;
uint32_t sin6_scope_id;
};

You can find a full list of address families on the address_families(7) - Linux manual page. (2022, September 26). Retrieved from https://man7.org/linux/man-pages/man7/address_families.7.html

Socket Types. You can find it as “Communication styles” too.

Type
Stream. UTP.
Datagram. UDP.

If type=SOCK_STREAM, then the sequence is the following:

sequenceDiagram
		    Note over Passive socket (server), Active socket (client): Create sockets
        Passive socket (server) ->> Passive socket (server): socket()
        Passive socket (server) ->> Passive socket (server): bind()
        Passive socket (server) ->> Passive socket (server): listen()
        loop block until client connects
          Passive socket (server) ->> Passive socket (server): accept()         
        end
		    Note over Passive socket (server), Active socket (client): Start connection
        Active socket (client)->> Active socket (client): socket()
        Active socket (client) ->> Passive socket (server): connect()
		    Note over Passive socket (server), Active socket (client): Start communication
        loop they transfers data
          Passive socket (server) --> Active socket (client): write()/read() or send()/recv()
        end
		    Note over Passive socket (server), Active socket (client): Close communication
        Passive socket (server) ->> Passive socket (server): close()
        Active socket (client)->> Active socket (client): close()

Reuse Port

How do I use setsockopt(SO_REUSEADDR)? (2022, September 26). Retrieved from https://stackoverflow.com/questions/24194961/how-do-i-use-setsockoptso-reuseaddr

Interlude

🕸️Tic-tac-toe Web on POSIX Sockets and WebRTC

References

Sockets (The GNU C Library). (2022, September 26). Retrieved from https://www.gnu.org/software/libc/manual/html_node/Sockets.html

TCP/IP Sockets in C: Practical Guide for Programmers, Second Edition

Sockets (The GNU C Library). (2022, September 24). Retrieved from https://www.gnu.org/software/libc/manual/html_node/Sockets.html

Beej's Guide to Network Programming, Using Internet Sockets

Coverage: [OSCJ8] Chapter 5 (pp. 193-239); [OSC8] Chapter 5 (pp. 183-223)?

rpc(3) - Linux manual page. (2022, September 26). Retrieved from https://man7.org/linux/man-pages/man3/rpc.3.html

Semaphores

Writers and readers

File system

Summary

References and notes

FAQ

What is the difference between POSIX, Single UNIX Specification, and Open Group Base Specifications?

https://unix.stackexchange.com/questions/14368/difference-between-posix-single-unix-specification-and-open-group-base-specifi

Windows 11

We introduce you to the most common APIs. If you want to know more, please consult the documentation.

Android

Interacting with Firmware

Live USBs

BIOS

UEFI

Operating systems for specific tasks

Cloud

Security

Synchronization tools

Shell vs terminal vs consola vs multiplexer vs cli

NameQue es?
ShellInterface de usuario para los servicios del sistema operativo.
TerminalInterface software para comunicarse a un servidor.
ConsolaInterface hardware para comunicarase a un servidor.
CLIShell por comandos. No graficos.
promptUbicacion actual dentro del sistema de archivos dentro de un CLI. Con base en las configuraciones puede aportar distinta informacion (git)
multiplexerVarias sesiones de inicio de sesion. con pseudo-terminales dentro de una sola teminal.
screen o demusComando para abrir una nueva terminal de un servidor externo. (multiplexer)
Untitled


Write your modern simple operating system from scratch, but it won’t be easy.