Talking about Operating System

Kernal

Windows 10

macOS / iOS

Ubuntu / Debian / Android

XNU-Mach (Darwin)

Windows NT

Linux

Windows 9x

Unix-like

Unix-like

Instruction Set Architecture

x86 / x86-64 / IA-64 / armv7

i386

amd64

👉🏼 Instruction Length, GPRegister Size

OP Code, Register, Operand, Data

Larger RAM address

Larger Register for Calculator

OK, too much!

Operating System Works

Process Scheduling

Memory Management

Sandbox, Compression, Virtualise...

File System

FAT32, exFAT, NTFS, HFS+, APFS, ext3, ext4, btrfs.....

Priority, malloc, thread

Device Access

Hard Disk, Keyboard, USB...

Network

Routing, Port Listening

API

System Call

Kernel / User mode

App

System Call

Device

Kernel Space Memory

Shell

Sh / Bash / ZSH

Shell Script

#!/bin/bash

PORT=8088
DEBUG=UCCU*

if [ "$1" = "stop" ]
then
  docker stop Sample
    
  echo "Sample Stopped"
else
  docker run -d -e "DEBUG=$DEBUG" -p "$PORT:80" --name Sample test.image

  echo "Sample Created"
fi

Everything is a file

Unix

Abstract everything to input and output, use file-like API to access resources.

File

Read File

Write File

Keyboard

Read Input

Network

Receive Packets

Send Packets

Process

Text - Program Codes

Data - Constants

Heap - Dynamic Allocate Memory

Stack - Function Call Link & Local Variables

Heap

Stack

var foo = 1;
var bar = foo;

1

foo

1

bar

Heap

Stack

var foo = 1;
var bar = foo;

bar = 2;

1

foo

1 ⇢ 2

bar

Heap

Stack

var foo = { yo: 'hi' };
var bar = foo;

ref

foo

ref

bar

{ yo: 'hi' }

Heap

Stack

var foo = { yo: 'hi' };
var bar = foo;

foo.yo = 'bye';

ref

foo

ref

bar

{

  yo: 'hi' ⇢ 'bye'

}

Heap

Stack

var foo = { yo: 'hi' };
var bar = foo;

foo.yo = 'bye';
bar = 'see u';

ref

foo

see u

bar

{

  yo: 'hi' ⇢ 'bye'

}

Heap

Stack

var foo = { yo: 'hi' };
var bar = foo;

foo.yo = 'bye';
bar = 'see u';
foo = 15;

15

foo

see u

bar

{

  yo: 'hi' ⇢ 'bye'

}

no refs will release by GC

One more thing

CSS line-clamp()

ellipsis for multi-line

CSS clamp()

clamp(MIN, VAL, MAX)

button.btn {
  width: clamp(80px, 50%, 320px);
}

CSS Scroll Snap

Thank you

adiós

Operating System

By Chia Yu Pai

Operating System

  • 559