Operating Systems Development Series Basic Theory
Operating Systems Development Series Basic Theory
This series is intended to demonstrate and teach operating system development from the ground up.
Introduction
Welcome to the wonderful and crazy world of operating systems!
In the previous tutorial, we have defined what an operating system is. An operating system provides the basic interface
between the user and the computer system. It provides the basic look and feel for the system.
We have also taken a look at alot of tools that will help us. Assemblers, Compliers, Linkers, PartCopy, MagicISO, and Bochs.
For anyone who has no programming experence who is reading this (I know there is some) shame on you :) Please go back
and reread the "Prerequisites" section from the first tutorial. Why are you still reading me? Go go go!
In this article, we are going to look at operating systems in a different way. We will first go Back in Time(tm) to look at the
history of operating systems. You will find there are many similarities between these operating systems. These similarities will
then be classified into the basic things operating systems have in common--and the building blocks for your own.
Alot of the concepts about operating systems date back sinse programs were on tape. Alot of these concepts still remain
active today.
The problem was that each program was completely different. They had to be simply because they had to be always
rewritten from scratch. There was no common support for the software, so the software had to communicate directly with
the hardware. This also made portability and compatibility impossible.
During the realm of Mainframe computers, creating code libraries became more feasable. While it did fix some problems, such
as two versions of software being completely different, each software still had full control of hardware.
If new hardware came out, the software will not work. If the software crashed, it would need to be debugged using light
switches from a control panel.
The idea of an interface between hardware and programs came during the Mainframe era. By having an abstraction layer to
the hardware, programs will no longer need to have full control, but instead they all would use a single common interface to
the hardware.
What is this ultra cool interface? Why, its that sweet cuddley (sometimes nasty) thing we call an Operating System! :)
http://www.brokenthorn.com/Resources/OSDev2.html 1/7
8/18/2015 Operating Systems Development Series
The SHARE Operating System (SOS) was the first OS to manage buffers, provide program sharing, and allow execution of
assembly language programs.
"Managing Buffers" relate to a form of "Managing Memory". "Program Sharing" relates to using libraries from different programs.
The two important things to note here are that,since the beginning of time (Not really :) ), Operating Systems are
responsible for Memory Management and Program Execution/Management
Because this isnt the history of the world (nor computers) that I am describing, lets jump now ahead to good old DOS.
A couple of important things to note is that DOS/360 offered no Multitasking, and no Memory Protection. The OS/360 was
being developed about the same time by IBM. The OS/360 used "OS/MFT" (Multiple Fixed Transactions) to support multiple
programs, with a Fixed Base Address. With OS/MVT (Multiple Varable Transaction), it can support varies program sizes.
Now we have a few more interesting words--Multitasking, Memory Protection, and Fixed Base Address. Adding to
before, we also have Program execution and Memory Management.
Unix includes a Kernel, File System and a Command Shell. There are alot of Graphical User Interfaces (GUI) that uses
the Command Shell to interact with the OS, and provide a much friendler and nicer look.
http://www.brokenthorn.com/Resources/OSDev2.html 2/7
8/18/2015 Operating Systems Development Series
Commodore DOS (CBM DOS) was used with Commodore's 8 bit computers. Unlike the other computers before or since-which
booted from disk into the systems memory at startup, CBM DOS executed internally within the drive-internal ROM chips, and
was executed by an MOS 6502 CPU.
The first Windows was a DOS application. Its "MSDOS Executive" program allows the running of a program. None of the
"Windows" could overlap, however, so each "window" was displayed side to side. It was not very popular.
http://www.brokenthorn.com/Resources/OSDev2.html 3/7
8/18/2015 Operating Systems Development Series
The second version of Windows was still a DOS Graphical Shell, but supported overlapping windows, and more colors.
However, do to the limitation of DOS, it was not widley used.
Note: DOS is a 16 bit operating system. During this timeframe, DOS had to refrence memory through Linear
Addressing, and disks through LBA (Linear Block Addressing). Because the x86 platform is backward compatible,
When the PC boots it is in 16 bit mode (Real Mode), and still has LBA. More on this later.
Do to 16 bit mode limitations, DOS could not access more then 1 MB of memory. This is solved, today, by enabling
the 20th address line through the Keyboard Controller. We will go over this later.
Because of this 1 MB limitation, Windows was far to slow, which was one primary reason of it being unpopular.
Windows 2.0 was completely redesigned. Windows 3.0 was still a DOS Graphical Shell, however it included A "DOS Extender"
http://www.brokenthorn.com/Resources/OSDev2.html 4/7
8/18/2015 Operating Systems Development Series
to allow access to 16 MB of memory, over the 1 MB limit of DOS. It is supports multitasking with DOS programs.
This is the Windows that made Microsoft big. It supportes resizable windows, and movable windows.
Basic Concepts
Looking back though our small trip to memory lane brings some important new terms with it. So far, we only gave "operating
system" a small definition. The previous section should help us in defining a better, more descriptive definition of what an
operating system is.
To help define a better definition, lets put the above bolded terms into a list:
Memory Management
Program Management
Multitasking
Memory Protection
Fixed Base Address
Multiuser
Kernel
File System
Command Shell
Graphical User Interface (GUI)
Graphical Shell
Linear Block Addressing (LBA)
Bootloader (From the previous tutorial)
Thats alot to think about, huh? And yet--The above list is techincally still an abstraction layer itself.
Memory Management
Memory Management refers to:
Dynamically giving and using memory to and from programs that request it.
Implimenting a form of Paging, or even Virtual Memory.
Insuring the OS Kernel does not read or write to unkown or invalid memory.
Watching and handling Memory Fragmentation.
Program Management
This relates cosely with Memory Management. Program Management is responsible for:
Multitasking
Multitasking refers to:
Memory Protection
This referrs to:
http://www.brokenthorn.com/Resources/OSDev2.html 5/7
8/18/2015 Operating Systems Development Series
A "Fixed" Base Address simply means that the program will always have the same base address each time it is loaded in
memory. Two example programs are the BIOS and the Bootloader.
Multiuser
This refers to:
Kernel
The Kernel is the heart of the Operating System. It provides the basic foundation, memory management, file systems,
program execution, etc. We will take a closer look at the kernel very soon, dont worry :)
File System
In OS Development, there is no such thing as a "file". Everything could be pure binary code (from the bootsector); from the
start.
A File System is simply a specification that describes information reguarding files. In most cases, this referrs to Clusters,
Segments, segment address, root directories, etc. the OS has to find the exact starting address of the file in order to load it.
File Systems also describe file names. There are external and internal file names. For example, the FAT12 specification
states a filename can only be 11 characters. No more, no less. Seriously. This means the filename "KRNL.sys", for example, will
have the internal file name
"KRNL SYS"
Command Shell
A Command Shell sits ontop the Kernel as a seperate program. The Command Shell provides basic input and output through
the use of typing commands. The Command Shell uses the Kernel to help with this, and complete low level tasks.
Graphical Shell
The Graphical Shell provides video routines and low level graphical abilities. It normally will be executed by the Command Shell.
(As in Windows 1.0,2.0, and 3.0). Useually this is automatic these days, however.
This is a good thing, but is also a very bad thing. For example:
http://www.brokenthorn.com/Resources/OSDev2.html 6/7
8/18/2015 Operating Systems Development Series
The above code seems harmless. However, if the above code was found in a bootloader, the above code will overwrite itself
by 10 bytes. Ouch. The reason is that bootloaders are loaded with a Fixed address of 0x7c00:0, and the above code starts
writing from 07bffh: One byte before 07c00h.
Bootloader
The bootloader. We seen this term from the previous tutorial. From the previous tutorial, we know the bootloader is loaded by
the BIOS, and is the very first program to execute for your operaing system.
The bootloader is loaded by the BIOS at absolute address 0x7c00:0. After loading, CS:IP is set to your bootloader, and the
bootloader takes full control.
A Floppy Sector is only 512 bytes in size. Remember that the bootloader has to fit in a single bootsector. What does this
mean? The bootloader is very limited in size, and cannot exceed 512 bytes.
Most of the time, the bootloader will either just load and execute the kernel, or a Second Stage Bootloader.
We will take a closer look at the booting process very soon. That is when we will look at bootloaders.
Conclusion
We have taken a look into the past, and learned a few more terms to our list. After the history lesson, we took the terms and
built a more broader perspective on how everything works. We even got to see some code. A small amount, though.
After all of this, one should be able to develope a more concise definition of what we are doing.
"An interactive envirement that provides an interface for the user and supplied programs, providing a stable and
safe envirement, an interface layer to System services and computer hardware."
In the next tutorial, we are going to take a look on the booting process in descrete detail. Afterwords, we will take a look at
building and assembling of a real bootloader.
~Mike
BrokenThorn Entertainment. Currently developing DoE and the Neptune Operating System
Would you like to contribute and help improve the articles? If so, please let me know!
Home
Chapter 1 Chapter 3
http://www.brokenthorn.com/Resources/OSDev2.html 7/7