Types of Operating System

There are roughly two types operating system that nowadays system uses: monolothic and microkernel.

It differs on where this two operating system's services located, basically.

Monolithic OS

Monolithic has all services lies on its kernel, using the same kernel's address space, which means, crash in monolithic can be catastrophic. It halts the entire PC.

Monolithic kernels can be compiled to be more modular, meaning that module can be inserted to and runs from the same space that handles core functionality (kernel space).

Example for this kind of operating system is Linux.

Microkernel OS
  • Advantage: small, failed service can easily be restarted.
  • Disadvantage: performance due to constant system call.

Taken from Wikipedia: a microkernel is a minimal computer operating system kernel which, in its purest form, provides no operating system services at all, only the mechanisms needed to implement such services, such as:

  • low-level address space management

  • thread management

  • inter-process communication (IPC).

So other OS services like file system, process management, or network protocols are running as user-level programs.

To be able to communicate between user-level program they use, for instance to a file system, you need to use the IPC (inter-process communication) from the OS.

Due to this circumstances, what in a monolithic kernel requires a single system call may require in a microkernel multiple system calls and context switches.

To elaborate this, when a program needs to use the disk, it needs to system call the IPC which will call the file system, subsequently, the file system, which a user-level program itself, needs to execute several system call before being able to get itself access to the disk.

An example of this OS would be MacOS.

Operating System Protection Boundary and System Call

Nowadays CPU has multiple ring (protections). Normal users (programs) have restrictions on giving CPU instructions, especially access hardwares like RAM, disk, GPU, etc.

Kernel-privileged programs has no limitation on giving CPU instructions. Operating system, for instance, is a program that operates under kernel mode.

For normal application to be able to access the underlying hardwares, it needs to ask on behalf of the operating system.

Operating system has an API served just for that specific purpose, each request is referred to as a “system call”. By specifying a predefined API, programs now have constriction on what it can do, thus making it much more safe for our application to not break the entire system.

For short: programs running in user mode can't directly access any hardware on it's own, it needs to ask the OS to do it for them, namely "system call". This occur due to safety, that is why operating system exist in the first place.

Services provided by OS includes scheduler, memory manager, block device driver, file system, and more. These service types categorize the huge list API.

Examples of the system call API and their corresponding services (in Windows OS):

File System:

  • CreateFile()
  • ReadFile()
  • WriteFile()

Device Manipulation:

  • SetConsoleMode()
  • ReadConsole()
  • WriteConsole()

Other things to note:

The compiler generates native machine code that can be run straight on the processor. The executable files that you get from the compiler, however, contain both the code and other needed data, for example, instructions on where to load the code in the memory.

When you make a system call, it is just an instruction in the machine code that calls the OS.

Introduction to Operating System

I have been really curious on the subject of operating system. Since I left my school days before I hit this subject, I suppose I can just learn this by myself. Couple of days ago I took the course on Udacity, tought by lecturers from University of Georgia, which also available on Youtube, for free.

Operating system sounds really fancy. But it turns out to be just another computer program like those we as a software engineer build day to day.

What differ is the purpose.

Operating system is a program that manages other programs.

It manages how each of our program uses the available resources such as the disk, memory, or processor.

It provide isolation and protection among applications, and hides hardware complexities through system calls (sort of API of using your hardware on behalf of the OS).

Examples of operating systems are Mac OS and Linux, which both are Unix-based. Other forms might include Android, iOS, and Symbian on embedded platforms.

A Little Question on FPS

Rendering optimization for web application requires us to know how to speed up FPS.

A display can have 60 Hz, 120 Hz, 144 Hz, or other variance (known as refresh rate).

60 Hz means that it will refresh the image it displays 60 times a second. So we can put up 60 images each second (60 fps), more images won't be displayed. If we have less images, say 30 fps, then two refreshes will display the same frame.

The question I have been wondering about is, what if I'm just looking at a static web pages without any events triggered to it.

Is the GPU still producing 60 fps of the same exact image, or maybe it does not produce any image at all?

If we take a look at Wikipedia's definition on GPU:

A graphics processing unit (GPU), occasionally called visual processing unit (VPU), is a specialized electronic circuit designed to rapidly manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device.

I suppose the display refreshes it screens and show images from the frame buffer.

If no events triggered, then the GPU does not need to alter the frame buffer.

What is the frame buffer anyway?

Well, go back to Wikipedia and we will find out that it is:

A framebuffer (frame buffer, or sometimes framestore) is a portion of RAM containing a bitmap that is used to refresh a video display from a memory buffer containing a complete frame of data.

It all makes sense now.

Encoding in 250 words

Computer speak in 1 and 0 (ones and zeroes), commonly referred to as binaries.

To produce character like A, 3, or ø it needs to know how to map each of those letters to binaries. Same situation applies when computer want to interpret data from binaries.

It may interpret a byte of 01000001 as A or perhaps B, depends on who sets up the rule in the first place.

Encoding basically a set of rule on mapping letters to binaries, and vice versa.

Know that a sequence of binary can be converted into to number (base 10) or hexadecimal (base 16). So keep it mind that a byte of 01000001 is equivalent to 65, and equivalent to 0x41 (0x indicates the that it’s a hex).

ASCII

One of the earliest encoding known is ASCII/ANSI.

They map decimal values from 0 to 127 to Western alphabets and control codes (tab, escape, backspace, etc) .

Mapping numerical values from 0-127 only takes up 7 bit of space. It does not specify numerical values from 128 to 255. So basically it wastes a bit for every byte. And it does not define characters for the rest of the world.

Unicode

Unicode isn’t necessarily an encoding but it does provide an interesting idea about code points.

All characters in the whole world is mapped to a form of U+WXYZ, whereas W, X, Y, and Z, are all hexadecimal values, which are able to hold numerical values 0-65535.

Now, there are several encoding to map this code points to real binaries:

  • UTF-7

  • UTF-8

  • UTF-16

  • UTF-32

Further readings:

Related concepts: