53
\section*{Statement of Originality}
54
This report is submitted as part requirement for the degree of ... at the University of Sussex. It is the product of my own labour except where indicated in the text. The report may be freely copied and distributed provided the source is acknowledged
62
\section*{Acknowledgments}
64
I would like to thank Dr. Martin Berger for his encouragement in choosing as dissertation topic that has been both challenging and exciting and for his support and advice throughout the project. I would furthermore like to express my gratitude to `maxdev' and the entire operating system development community for their help during the initial phases of the project.
66
I would also like to thank Dr. John Rochester for providing me with the physical resources required to test and demonstrate the project's Operating System.
77
We live in a world surrounded and controlled by machines, and software is our way of telling those machines how to act. As our machines and needs become more complex, so must the software that runs them. An Operating System is a software package that allows for others to easily create complex behaviors by providing simple high level abstractions over the intricate low level hardware. This project involves creating an Operating System with the aim of exploring low level hardware and software relation ships and creating a platform upon which others can develop arbitrarily complex software.
79
This dissertation describes the processes of creating such this Operating System (herein called MOS) in the C programming language along with a set of supporting programs, including an analysis of similar systems and a look into the implementation of MOS.
81
The main sections of this dissertation include:
83
\item An introduction to Operating Systems.
84
\item Professional and ethical considerations for the project.
85
\item Requirements analysis for the Operating System including a look at other modern operating systems
86
\item The implementation of the system.
87
\item The testing techniques used to ensure the system produces is of high quality
88
\item A conclusion to the project.
101
Operating Systems come with a large variety of terms and phrases that are unique to their nature, This section serves as a description of the terms that may be required to understand the remainder of this document:
103
\begin{minipage}{.5\textwidth}
107
\item CPU : Central Processing Unit, This is the part of the physical computer that performs all the operations that processes contain.
108
\item BIOS : The BIOS is the part of the physical computer that is started when the computer is turned on, it has limit functionality and its job is to get the CPU started.
109
\item IO : Input/Output, IO refers to a processes ability to interact with external services such as receiving keyboard keys(input) or displaying information to a screen(output)
110
\item RAM : Random Access Memory, This is the part of the physical computer that stores temporary information such as the state of running processes.
111
\item HDD/Hard Drive : This is the part of the physical computer that can store information that remains persistent even if the computer is turned off.
112
\item MOS : Michael's Operating System, the name of the Operating System produced as part of this project.
115
\begin{minipage}{.5\textwidth}
119
\item Kernel : The kernel is the main part of the Operating System that allows access to hardware and provides services to the user space.
120
\item Kernel space : This is the part of the running system that is only accessible by the kernel, here the kernel keeps track of system state and other useful informations.
121
\item User space : This is the part of the running system in which programs and processes are executed. Here these programs can keep track of their state. In this area, there is less direct access to the hardware of the computer.
122
\item System Call : System calls are the way that user space applications gain access to the kernel, they each provide access to a different kernel service or to a piece of hardware.
123
\item Process : A processes is one set of instructions and a current state. A processes is `run' by the CPU.
124
\item Program / Application : A program is a tool that users can use to perform tasks in the system. Typically a program will consist of one process that is to be run by the system. Programs are ofter interactive or take `parameters' to customize the task they perform. Programs can also consist of many processes if they with to do more than one thing at once.
125
\item Interrupts : These are events in the kernel space that take place when either a piece of hardware want attention (a key is pressed on the keyboard or a hard drive finishes writing some data). Or when a piece of software misbehaves (dividing by zero or attempting to access kernel space.)
40
133
\chapter{Introduction}
42
The overall aim for this project is to produce a simple Multitasking Operating System (herein called MOS) to study structure, allocation, and management of different classes of hardware resource. This section provides a brief introduction to Operating Systems, Discusses the project aims, and looks at the approach taken.
44
We live in a world surrounded and controlled by machines, and software is our way of telling those machines how to act. As our machines and needs become more complex, so must the software that runs them. An Operating System is a software package that allows for others to easily create complex behaviors by providing simple high level abstractions over the intricate low level hardware.
135
The overall aim for this project is to produce a simple Multitasking Operating System to study structure, allocation, and management of different classes of hardware resource. This section provides a brief introduction to Operating Systems, Discusses the project aims, and looks at the approach taken.
68
156
Operating Systems come in all different shapes and sizes, each with its own look, feel, and utility.
70
For an every day user, the Operating System turns complex tasks into seemingly trivial ones. Even running a program is a complex task for a computer to achieve, however to most users `launch your favourite browser' might seem like the simplest task to accomplish. Operating Systems make these tasks easy by providing graphical menus and windows to `disguise' the complexity beneath. It may also provide a number of built in programs like file browsers and settings managers to make common tasks even more straight forward.
72
An Operating system may also offer tailoring of a system to a specific user, like having certain programs start when the computer is turned on, or drawing the screen with a custom image as a background. To this extend, the Operating System can be seen as `anything that isn't a program' to the user.
74
Below is a screen shot of the popular Windows operating system, It shows a number of programs; a web browser `firefox', a test editor `notepad++', a file browser `explorer'. The programs each own and control their `window' however all other parts of the screen are controlled by the Operating System. On the right, the portions of the screen controlled by the programs is blacked out, showing only the parts of the screen controlled by the operating system.
158
For an every day user, the Operating System turns complex tasks into seemingly trivial ones. Even running a program is a complex task for a computer to achieve, however to most users `launch your favorite browser' might seem like the simplest task to accomplish. Operating Systems make these tasks easy by providing graphical menus and windows to `disguise' the complexity beneath. It may also provide a number of built in programs like file browsers and settings managers to make common tasks even more straight forward.
160
An Operating system may also offer tailoring of a system to a specific user, like having certain programs start when the computer is turned on, or drawing the screen with a custom image as a background. To this extent, the Operating System can be seen as `anything that isn't a program' to the user.
162
As in the title, this project is concerned with multitasking operating systems. A multitasking system is one that can perform more than one task at once. Most major consumer Operating systems are multitasking (from PC operating systems like Microsoft's Window to mobile operating systems such as Google's Android). However not all are, many systems require only one task to be performed at one time, for example ATM's or self checkouts at supermarkets.
164
Below is a screen shot of the popular Windows operating system, It shows a number of programs; a web browser `firefox', a test editor `notepad++', a file browser `explorer'. The programs each own and control their `window' however all other parts of the screen are controlled by the Operating System. On the right, the portions of the screen controlled by the programs are blacked out, showing only the parts of the screen controlled by the operating system.
77
167
\begin{figure}[ht]
89
179
\caption{A screen shot of the Windows operating system.}
92
The operating system is doing more than just running 3 programs though. Each program can have any number of `processes'. A process is a piece of a program that can perform one action at a time. If a program wants to do two things at a time, it must have two processes. Furthermore there may be more processes running that don't belong to a graphical program and are needed to keep the system running often referred to a system processes. The Operating System must make sure each of these processes gets a fair share of the computer, to make sure each program can run correctly.
94
Processes, whether they are program processes or system processes, need to access a number of resources to work. The most apparent are the screen, the keyboard, and the mouse. Operating systems gives the processes simple access to these resources to allow programs to show things to the user, and allows the user to interact with them. However, in the back ground, there are many other types or resources that the Operating System controls. Hard Drives are permanent storage services, they allow programs and users to create information that lasts even after a reboot. RAM is a temporary storage that allows programs to keep track of there current state (for example, storing the text and images for your current word document). Network devices such as ethernet cards and wifi cards allow programs to communicate with other programs on other computers and connect to the internet.
96
These resources are not infinite. Hard Drives, RAM, and screen space, are restricted by size. Whereas network cards, and printers, are restricted by throughput (actions per minute). An Operating System tries to allow access to all these resources by all processes simultaneously. By denying a process access to a specific resource, the program may not be able to perform its task correctly. However, to a program, fair may not mean equal. A web browser my heavily use network card, but never write to the Hard Disk, Alternatively, A Photo Editor may never require network access, but may write very large amounts to the Hard Disk.
182
The operating system is doing more than just running 3 programs though. Each program can have any number of `processes'. A process is a piece of a program that can perform one action at a time. If a program wants to do two things at once, it must have two processes. Furthermore there may be more processes running that don't belong to a graphical program and are needed to keep the system running often referred to a system processes. Here the importance of a multitasking system is even more apparent, Windows may be running up to 60 system processes simultaneously just to keep the system ready to respond to the users requests. The Operating System must make sure each of these processes gets a fair share of the computer, to make sure each program can run correctly.
184
Processes, whether they are program processes or system processes, need to access a number of resources to work. The most apparent are the screen, the keyboard, and the mouse. Operating systems gives the processes simple access to these resources to allow programs to show things to the user, and allows the user to interact with them. However, in the background, there are many other types or resources that the Operating System controls. Hard Drives are permanent storage services, they allow programs and users to create information that lasts even after a reboot. RAM is a temporary storage that allows programs to keep track of there current state (for example, storing the text and images for your current word document). Network devices such as Ethernet cards and wifi cards allow programs to communicate with other programs on other computers and connect to the Internet.
186
These resources are not infinite. Hard Drives, RAM, and screen space, are restricted by size. Whereas network cards, and printers, are restricted by throughput (actions per minute). An Operating System tries to allow access to all these resources by all processes simultaneously. By denying a process access to a specific resource, the program may not be able to perform its task correctly. However, to a program, fair may not mean equal. A web browser may heavily use network card, but never write to the Hard Drives, Alternatively, A Photo Editor may never require network access, but may write very large amounts to the Hard Drives.
98
192
This high level `user perspective' of an Operating System is important to keep in mind through out this project as ultimately the users are the target demographic of the system. However to produce an Operating System a much more in-depth understanding is required.
103
An Operating System is higly a complex piece of software however all require 3 distinct sections:
197
An Operating System is highly a complex piece of software however all require 3 distinct sections:
105
199
The kernel is the software that drives the hardware. It provides nice abstractions and interfaces to control the very fiddly underlying machine.
107
The Bootloader is the code that is run first. It gets things that the kernel might need set up, for example, getting the CPU into the correct operation mode.
201
The Boot-loader is the code that is run first. It gets things that the kernel might need set up, for example, getting the CPU into the correct operation mode.
109
203
The Final part is a collection of programs and other software that come with the Operating System. Although some people would argue this is not so much part of the Operating System, on some systems (namely Microsoft's Windows) a huge number of these programs are built right in, and seem from the outside to be part of the kernel.
119
213
\label{fig:thekernel}
122
The kernels job is to both control the hardware and mediate the execution of processes. To begin with it will initialise its modules, each there to control one piece of hardware or provide one service to the kernel or user-space. Some of the more important task these modules perform are keeping track of which processes are currently executing, deciding which processes should go next, as well as ensuring that all processes think they have enough memory to operate correctly.
216
The kernel's job is to both control the hardware and mediate the execution of processes. To begin with it will initialize its modules, each there to control one piece of hardware or provide one service to the kernel or user-space. Some of the more important task these modules perform are keeping track of which processes are currently executing, deciding which processes should go next, as well as ensuring that all processes think they have enough resources to operate correctly.
124
218
Once the kernel is happy that everything is in order, it will begin execution of the first process. For the rest of the time the computer is on, `processes' will be run. These processes each having a unique environment. In fact as far as a process is concerned, it owns the whole computer. However, as programmers are aware that each process does not own the whole computer, they can program complex interprocess interactions, with the kernels help of course.
129
\subsection{The Bootloader}
223
\subsection{The Boot-loader}
131
225
\begin{figure}[ht]
135
229
\label{fig:theloader}
138
The bootloader's job is to load the kernel. The CPU has to begin executing code somewhere, this is the boot loader.
140
The majority of the bootloader's job is to get the hardware ready for the kernel to take over. Tasks like detecting the available physical memory of a machine is up to the bootloader, once it has gathered such information, the loader will store it somewhere the kernel can find it.
142
The final steps of the bootloader are to get the CPU into the right mode. It does this by first setting up some important `tables' in memory. One of these tells the CPU what to do if an interrupt is produced. Another tells the CPU where it can find physical addresses in RAM when virtual addresses are looked up.
144
Finally the bootloader can start the kernel and it's job is finished.
232
The boot-loader's job is to load the kernel. The CPU has to begin executing code somewhere, this is the boot loader.
234
The majority of the boot-loader's job is to get the hardware ready for the kernel to take over. Tasks like detecting the available physical memory of a machine is up to the boot-loader, once it has gathered such information, the loader will store it somewhere the kernel can find it.
236
The final steps of the boot-loader are to get the CPU into the right mode. It does this by first setting up some important `tables' in memory. One of these tells the CPU what to do if an interrupt is produced. Another tells the CPU where it can find physical addresses in RAM when virtual addresses are looked up.
238
Finally the boot-loader can start the kernel and it's job is finished.
146
240
\subsection{The Built in Programs}
280
374
\chapter{Requirements Analysis}
282
In preparation of producing an Operating System, current generation systems were studied in detail. The features and interfaces of the systems were analysed to assist in the designing of MOS. Although It was known in advanced that MOS was not going to be complex enough to incorporate all features of the reference systems, it was important to study what current systems do, such that their most important features could be mimicked.
376
In preparation of producing an Operating System, current generation systems were studied in detail. The features and interfaces of the systems were analyzed to assist in the designing of MOS. Although It was known in advanced that MOS was not going to be complex enough to incorporate all features of the reference systems, it was important to study what current systems do, such that their most important features could be mimicked.
284
378
Modern Operating Systems are such that there are two user groups.
287
381
The End Users are the people using the Operating System and its programs to assist in achieving an assortment of tasks. To them, the Operating System provides a few simple mechanisms to interact with the system, E.G. Launching programs, closing programs, and switching between the `focused' program. Most of the inner workings of the Operating System are hidden from the end user, and they mainly interact with the `User space programs', which are not defined by the Operating System Developer.
290
The Program Developers use an Operating System as a platform to create the programs the End User will use. To them, the Operating System is a Resource Manager and Scheduler and provides some crucial functionality for complex behaviours like creating new processes, Allocating dynamic memory, allocating screen space to the programs, and accesing the hard drive. Many of the complexities of the Operating System (especially hardware control) are abstracted away from the Program Developers, however it is expected that they have some awareness of how the system is structured to successfully integrate with the kernel.
384
The Program Developers use an Operating System as a platform to create the programs the End User will use. To them, the Operating System is a Resource Manager and Scheduler and provides some crucial functionality for complex behaviors like creating new processes, Allocating dynamic memory, allocating screen space to the programs, and accessing the hard drive. Many of the complexities of the Operating System (especially hardware control) are abstracted away from the Program Developers, however it is expected that they have some awareness of how the system is structured to successfully integrate with the kernel.
298
392
\section{The End User}
299
393
The reference systems that were studied with the End Users in mind are: The Linux distribution remix `Gnomebuntu' and the Microsoft Operating System `Windows 8'. These systems were chosen to get a spread in our sample. The systems are both popular desktop systems, however: One, (Linux) is stemmed from an open source mentality, where the source code is freely available and the system is free, and the other (Windows) is produced by a company with the aim to provide paying business, and home customers with a usable system.
301
The parts of the reference systems that were analysed from the end users perspective are; program launching, process management, and program interaction as these are the main sections that will be implemented in the MOS.
395
The parts of the reference systems that were analyzed from the end users perspective are; program launching, process management, and program interaction as these are the main sections that will be implemented in the MOS.
303
397
\subsection{Launching programs in Linux and Windows}
315
409
\begin{minipage}{.5\textwidth}
317
411
\includegraphics[width=200px]{images/Windows_Program_Launcher_Screenshot}
318
\caption{Windows Program Launcher Interface}
412
\caption{Windows program launcher interface}
319
413
\label{fig:WinLaunchScreen}
321
415
\begin{minipage}{.5\textwidth}
323
417
\includegraphics[width=200px]{images/Linux_Program_Launcher_Screenshot}
324
\caption{Linux Program Launcher Interface}
418
\caption{Linux program launcher interface}
325
419
\label{fig:LinLaunchScreen}
332
426
Both reference systems provide a way of interacting directly with the process manager to give the user power over which programs are running on their system.
334
In each system, the process manager is very similar, as the tasks they perform are identical. Both systems provide a window that lists processes and some relevant information about each process like PID, cpu usage, memory usage, disk usage, and network usage. It was found that the majority of these fields are concerned with what resources a process is using. This is the case because an Operating System's purpose is to manage the physical resources available to the software.
428
In each system, the process manager is very similar, as the tasks they perform are identical. Both systems provide a window that lists processes and some relevant information about each process like PID, CPU usage, memory usage, disk usage, and network usage. It was found that the majority of these fields are concerned with what resources a process is using. This is the case because an Operating System's purpose is to manage the physical resources available to the software.
336
Each system also provides the ability to change what information is provided for each process, these extra informations include many other physical resource usages (I.E. Nice value, or cpu time) as well as a more in depth view of the default informations (I.E. separating `memory usage' into: Virtual, Resident, Writeable, Shared, and Xserver memory.)
430
Each system also provides the ability to change what information is provided for each process, these extra informations include many other physical resource usages (I.E. Nice value, or CPU time) as well as a more in depth view of the default informations (I.E. separating `memory usage' into: Virtual, Resident, Write-able, Shared, and X server memory.)
338
432
In each system this list was scrollable, allowing for many more processes that can fit in the window, furthermore the window becomes horizontally scrollable if the information exceeds the width of the screen.
346
440
\begin{minipage}{.5\textwidth}
348
442
\includegraphics[width=200px]{images/Windows_Program_Manager_Screenshot}
349
\caption{Windows Program Manager Interface}
443
\caption{Windows program manager interface}
350
444
\label{fig:WinProcManScreen}
352
446
\begin{minipage}{.5\textwidth}
354
448
\includegraphics[width=200px]{images/Linux_Program_Manager_Screenshot}
355
\caption{Linux Program Manager Interface}
449
\caption{Linux program manager interface}
356
450
\label{fig:LinProcManScreen}
365
459
In both the reference systems, the programs were presented in `floating', overlapping windows. These windows share the screen space by having the `active' window draw on top of all other windows. The system provides a way or moving, hiding, and resizing the windows to customize your workspace. Both systems provide similar mechanics for achieving this. They each provide a `title bar' that can be grabbed and dragged around to move the window. Each also provide the ability to grab the very edge of any side of any window, or the corners, to resize the window to the desired size. Finally, each system provides buttons to manipulate the windows more directly. This is where the systems begin to differ.
367
The Windows Operating System provides three buttons; The first Button allows the user to minimize the window to hide it from the work space. The second button is to maximize/un-maximize the window, this makes the window occupy the entirety of the screen. The final button exits the application.
461
The Windows Operating System provides three buttons; The first Button allows the user to minimize the window to hide it from the work space. The second button is to maximize/unmaximize the window, this makes the window occupy the entirety of the screen. The final button exits the application.
369
463
The Linux Operating System only provides an exit button.
373
467
\begin{figure}[ht]
375
469
\includegraphics[width=200px]{images/Windows_title_bar_screenshot}
376
\caption{Windows Title Bar Example}
470
\caption{Windows title bar example}
377
471
\label{fig:WinTitleBarScreen}
380
474
\begin{figure}[ht]
382
476
\includegraphics[width=200px]{images/Linux_title_bar_screenshot}
383
\caption{Linux Title Bar Example}
477
\caption{Linux title bar example}
384
478
\label{fig:LinTitleBarScreen}
387
481
Because of the nature of overlapping windows on both systems, it is possible for one window to be drawn entirely `under' another window. In Windows it is in fact possible to choose to hide a window from the workspace completely. In this situation the systems both provide different ways to navigate back to the `hidden' window.
389
On windows, There is a `task bar'. This is a portion of the screen, (often located at the bottom of the screen), that stores small icons for each running program. Clicking on one of these icons will bring that program to the front, un-minimize it, and make it the `active' program.
483
On windows, There is a `task bar'. This is a portion of the screen, (often located at the bottom of the screen), that stores small icons for each running program. Clicking on one of these icons will bring that program to the front, unminimize it, and make it the `active' program.
391
On Linux, Pressing the windows key, or pointing your mouse cursor to the corner of the screen shows you all of the open programs by `zooming out' and separating all the programs from each other. Selecting a program from this `exploded' view will un-minimize this window, bring it to the front, and make it the active window.
485
On Linux, Pressing the windows key, or pointing your mouse cursor to the corner of the screen shows you all of the open programs by `zooming out' and separating all the programs from each other. Selecting a program from this `exploded' view will unminimize this window, bring it to the front, and make it the active window.
393
487
Figure \ref{fig:WinWinNavScreen} and \ref{fig:LinWinNavScreen} give example of these Navigation features.
397
491
\begin{minipage}{.5\textwidth}
399
493
\includegraphics[width=200px]{images/Windows_Window_Navigation_Screenshot}
400
\caption{Windows Program Navigation Interface}
494
\caption{Windows program navigation interface}
401
495
\label{fig:WinWinNavScreen}
403
497
\begin{minipage}{.5\textwidth}
405
499
\includegraphics[width=200px]{images/Linux_Window_Navigation_Screenshot}
406
\caption{Linux Program Navigation Interface}
500
\caption{Linux program navigation interface}
407
501
\label{fig:LinWinNavScreen}
415
509
To understand how program developers interact with Operating Systems The Linux distribution remix `Gnomebuntu' was studied. Only one system here was studied as Linux is an open source system. This meant that the system could be looked at in more depth.
417
The parts of the Linux system that were analysed are the; Process management system, the memory management system, the windowing system, and Inter Process Communication.
511
The parts of the Linux system that were analyzed are the; Process management system, the memory management system, the windowing system, and Inter Process Communication.
419
513
\subsection{Managing processes in Linux}
515
Managing processes for the program developers is a very import tool in multitasking systems. Being able to create new processes and define their behavior allows for true programs to perform more than one task at once, even if one process is waiting on a resource or some user input, another processes from the same program can be performing calculations or updating the screen. Being able to destroy processes allows for resources to be freed explicitly and allows for the killing of malicious programs. Pausing processes for sections of time allow program developers to temporarily free up resources to make way for other processes, this can be to allow faster execution of other services or to save power on mobile devices.
421
517
Linux exposes a number of system calls to the program developers to allow them to create, destroy, and pause processes, and also change the current `executable' to allow for new programs to be run.
473
571
\subsection{Inter Process Communication in Linux}
475
Communication between processes is an important part of creating complex behaviours in user space programs. Linux provides some simple calls to create channels of communication between processes.
573
Communication between processes is an important part of creating complex behaviors in user space programs however it is one of the more complex sub-systems of an operating system. This is due to the idea that each processes should believe it has total access to the computer and not be able to directly interact with another processes memory. Because of this many different versions of IPC have been formulated. Some create a special portion of the kernel to hold all the information in the communication channels and then give it to the processes on demand. Others create a piece of user-space memory that is accessible by two or more processes. Finally some systems copy the memory from one process' space to the others.
575
Furthermore some system also implement different policies for reading and writing to pipes; Some systems use `blocking' system calls, meaning that if the pipe is empty, the read system call will wait until the pipe is no longer empty, effectively pausing the calling processes until this time.
577
Linux can be said to use the first method for storing the pipe. When a pipe is created Linux creates a file in a virtual file system (a file system that lives only in kernel memory). Any process that has the handle to this virtual file (aka has the pipe handle) can write or write to the pipe. Linux also does not include blocking system calls for pipes, this is because it believes the user space should have control over when it is blocked or not.
579
Linux provides some simple calls to create channels of communication between processes.
478
582
\textbf{Creating a pipe.}
493
597
It was found that in end user design, many systems share similar design features. These features are very rich and operate do to a wide collection of tool, utilities, and applications. The most important of these feature should be mimicked in new systems to assist new users in understanding how the the system works, However due to time constraints MOS will target much simpler versions of these features.
495
From the programmers perspective. The system API's or modern Operating Systems have been well thought out and have stood the test of time, however sometimes represent behaviours far more complex than that which MOS targets. The studied API's will be mimicked both to follow tried and tested ideas, and also so that program developers feel at home developing for MOS.
599
From the programmers perspective. The system API's on modern Operating Systems have been well thought out and have stood the test of time, however sometimes represent behaviors far more complex than that which MOS targets. The studied API's will be mimicked both to follow tried and tested ideas, and also so that program developers feel at home developing for MOS.
532
As with the Analysis, the Design phase was separated into End User and Program Developer sections. However here the structure of the kernel itself was also considered and planned. The designs presented here are the final designs for the system, some earlier versions can be found in TODO Link to apendix here.
636
As with the Analysis, the Design phase was separated into End User and Program Developer sections. However here the structure of the kernel itself was also considered and planned. The designs presented here are the final designs for the system, some earlier versions can be found in TODO Link to appendix here.
534
Design for the end user focused on similar tools, looks, and controls to existing systems; The Linux CLI was referenced for a lot of the simple command line tools as MOS' text mode graphics share a common interface to Linux terminals. MOS programs also targeted a clean workspace, avoiding unnecessary ascii drawing and focussing on delivering the service provided in a quick and clean manner.
638
Design for the end user focused on similar tools, looks, and controls to existing systems; The Linux CLI was referenced for a lot of the simple command line tools as MOS' text mode graphics share a common interface to Linux terminals. MOS programs also targeted a clean workspace, avoiding unnecessary ASCII drawing and focusing on delivering the service provided in a quick and clean manner.
536
640
Program Developer design was constructed with a `many simple tools' structure. Each system call the standard library contained was made to perform one task, rather than bunching many tasks into one more complex call. This allows developers to maintain simple, intuitive control over their resources.
586
690
As shown, this tool will show the user information about each running processes and afford them the ability to kill these processes.
588
\subsection{File/Directory creation: mkdir and touch}
692
\subsection{File/Directory creation: `mkdir' and `touch'}
590
694
MOS will provide two programs for creating files and directories. touch will create empty files and mkdir will create directories. Both programs will operate in a similar way, taking an absolute path as their only parameter. Neither will create anything unless the parent directory of the wanted object exists, and the parameter is well formed (with a trailing / for directories).
592
\subsection{File/Directory Management: rm and mv}
696
\subsection{File/Directory management: `rm' and `mv'}
594
698
For file and directory management MOS will provide two functions.
636
740
\section{The Program Developers}
638
As program developers are very familiar with how to create programs for other systems, the API for the project system was designed to be very similar to that of the Linux kernel that was analysed.
742
As program developers are very familiar with how to create programs for other systems, the API for the project system was designed to be very similar to that of the Linux kernel that was analyzed.
640
744
\subsection{Managing processes}
642
MOS will provide a very similar set of system calls to Linux, however their behaviour may be simpler.
746
MOS will provide a very similar set of system calls to Linux, however their behavior may be simpler.
644
748
These features were considered independently of each other except for creating a new process and changing the current executable, as these calls are so commonly used together.
728
832
\subsection{File Access}
730
The File access functions will use a similarly idea to linux's however will be far simpler.
834
The File access functions will use a similarly idea to Linux's however will be far simpler.
734
`fopen(name, \&file\_handle, create)' will open the file specified by the absolute path `name' and store the relelvent information into the file handle provided. If the file does not exist and the `create' parameter is true, the file will be created. If the directory does not exists, no action will be taken. If the file does not exist or any other error occurs, the type field of the file handle will be set to 2. The rest of the structure will be considered invalid.
838
`fopen(name, \&file\_handle, create)' will open the file specified by the absolute path `name' and store the relevant information into the file handle provided. If the file does not exist and the `create' parameter is true, the file will be created. If the directory does not exists, no action will be taken. If the file does not exist or any other error occurs, the type field of the file handle will be set to 2. The rest of the structure will be considered invalid.
798
902
\section{The Kernel}
800
The kernel was split into a number of discrete modules, each performing one simple task, or over seeing the access to one peice of hardware. These modules were originally designed to be self contained, not relying on any other modules, however it was quickly realised that some modules could be brought `closer together' to help streamline the kernel. The most notable case of this is the scheduler and the terminal manger, the scheduler contains the process entries for each running application, including the io descriptors, these io descriptors are required by the terminal to operate, therefore the scheduler allows write access to these data structures `cross module'.
904
The kernel was split into a number of discrete modules, each performing one simple task, or over seeing the access to one piece of hardware. These modules were originally designed to be self contained, not relying on any other modules, however it was quickly realized that some modules could be brought `closer together' to help streamline the kernel. The most notable case of this is the scheduler and the terminal manger, the scheduler contains the process entries for each running application, including the IO descriptors, these IO descriptors are required by the terminal to operate, therefore the scheduler allows write access to these data structures `cross module'.
802
906
The Kernel Loader can also be seen as a kernel module however it is special in that it does its job once at boot, and then does nothing for the remainder of the computers uptime.
833
937
The Kernel Loader can actual be seen as more of a kernel in its own right. It is the code that is loaded by our Boot loader (GRUB). The loaders job is to to correctly configure the hardware in the CPU's Real Mode and then switch over to Protected Mode for the rest of the uptime of the CPU.
835
It has its own smaller Physical Memory Manager, IO Manager and XXX, To assist in its task. It then maps the kernel to the correct location in memory and jumps to the kernels entry point.
939
It has its own smaller Physical Memory Manager and IO Manager, To assist in its task. It then maps the kernel to the correct location in memory and jumps to the kernels entry point.
837
941
Since the kernel only executes in Protected mode, it has less direct access to physical memory, therefore the kernel loader must initialize the memory map for the Physical Memory Manager module and map this memory map into a suitable Virtual memory location.
843
947
\subsection{The Program Loader}
845
The program loaders job is to prepare a Program for execution; Loading the binary into memory in an appropriate manner, setting all process table fields to correct values, and ensuring all other system modules correctly reflect the execution of a new program.
949
The program loader's job is to prepare a Program for execution; Loading the binary into memory in an appropriate manner, setting all process table fields to correct values, and ensuring all other system modules correctly reflect the execution of a new program.
847
951
\subsection{The Event Manager}
849
The event managers job is to track timed events. It will allow for the registration of certain types of events with an event deadline. Once the deadline is passed the Event manager will perform the requested action. This module requires that its main function 'events()' be called with some frequency.
953
The event manager's job is to track timed events. It will allow for the registration of certain types of events with an event deadline. Once the deadline is passed the Event manager will perform the requested action. This module requires that its main function `events()' be called with some frequency.
851
955
\subsection{The Pager}
879
983
\subsection{The IO Manager}
881
The IO manager will control all IO for user interaction with processes, as well as any outputting the kernel may do. It must maintain a current rendering of all running processes screen space, and deliver keyboard input to user space processes at the users command. It should also maintain different kernel space and user space windows, allowing for the user to switch between the kernel and user process view.
883
\subsection{Keyboard Driver}
985
The IO manager will control all IO for user interaction with processes, as well as any outputting the kernel may do. It must maintain a current rendering of all running process' screen space, and deliver keyboard input to user space processes at the users command. It should also maintain different kernel space and user space windows, allowing for the user to switch between the kernel and user process view.
885
988
The keyboard Driver handles keyboard input to the system, Its main job is to correctly pass signals along to the IO manager such that they can be sent to user space processes, however it may also detect system commands (like ctrl+tab and F1) and call the respective module to perform the expected action.
977
1080
This structure is very slow when searching for processes with specific attributes, and also contains no information about the order in which processes were created. For these reasons the Scheduler also contains a number of linked lists, each storing a list of PID's of processes that are `interesting' in some way.
979
The active process list contains all processes that either want CPU time, or are known to want CPU time in the future. The list is ordered in such that the process at the front is always the lest recent to have had CPU time.
1082
The active process list contains all processes that either want CPU time, or are known to want CPU time in the future. The list is ordered in such that the process at the front is always the least recent to have had CPU time.
981
1084
Using a linked list to store the active processes makes it very fast to select a new process to run, and as the scheduler maintains a handle to both ends of the list, both getting the first item in the list and putting something at the back of the list is O(1) time.
1075
1178
The IO manager first appends this process to its `outputable' list and populates the IO part of the respective processes table entry with the remainder of the metrics, filling the column and row potion with 0 and 0.
1077
It then checks for any overlapping processes, these are processes that are in the `outputable' list who's screen area collides with the new request. For any overlapping processes, the IO manager first pauses that processes, giving it the is\_hidden flag. Then it uses malloc() to request a portion of the kernels heap space of the same size as the old processes screen space. It copies the current state of this screen space into the new memory and assigns the pointer into the `snapshot' section of the IO part of the process entry. It then moves the processes from the `outputable' list to the `hidden' list. Finally it wipes the process' portion of the screen blank.
1180
It then checks for any overlapping processes, these are processes that are in the `outputable' list who's screen area collides with the new request. For any overlapping processes, the IO manager first pauses that processes, giving it the is\_hidden flag. Then it uses malloc() to request a portion of the kernels heap space of the same size as the old process' screen space. It copies the current state of this screen space into the new memory and assigns the pointer into the `snapshot' section of the IO part of the process entry. It then moves the processes from the `outputable' list to the `hidden' list. Finally it wipes the process' portion of the screen blank.
1079
1182
The above procedure ensures that, from a processes perspective, it always has full control over a portion of the screen. This is because when a process doesn't have control of that part of the screen, the process is paused and cannot be executed.
1081
1184
When the user requests to see one of the hidden processes, the IO manager repeats the process above, but instead checks for overlapping with the process that the user wants to bring to the front. Once any overlapping processes have been correctly hidden, it copies the snapshot of the requested process back to the correct area of the screen and unpauses it, moving it back to the `outputable' list.
1083
The IO manager supports two output modes for processes; progressive and targeted. In progressive mode, the IO Manager keeps track of the current position of each processes `caret'. Then, if a processes wants to print in this mode, the processes simply passes a character to the IO manager. The IO manager will use the column and row fields of the IO part of the process entry to place the character within the processes screen space. The IO manager will make sure to wrap when the end of the line is reached, and will also roll the entire process' terminal space up when the bottom is reached. This behavior is very similar to that seen in the Linux and Windows CLI's.
1186
The IO manager supports two output modes for processes; progressive and targeted. In progressive mode, the IO Manager keeps track of the current position of each processes `caret'. Then, if a processes wants to print in this mode, the processes simply passes a character to the IO manager. The IO manager will use the column and row fields of the IO part of the process entry to place the character within the process' screen space. The IO manager will make sure to wrap when the end of the line is reached, and will also roll the entire process' terminal space up when the bottom is reached. This behavior is very similar to that seen in the Linux and Windows CLI's.
1085
In targeted mode the process sends the IO manager both a character and a coordinate for that character. The IO manager will then check if the coordinate is within the bounds of the processes screen space and if so, draw it to the screen. This draw mode allows more sophisticated user-space applications to `draw' better gui's and update only portions of the screen space at a time.
1188
In targeted mode the process sends the IO manager both a character and a coordinate for that character. The IO manager will then check if the coordinate is within the bounds of the process' screen space and if so, draw it to the screen. This draw mode allows more sophisticated user-space applications to `draw' better GUI's and update only portions of the screen space at a time.
1088
1191
\section{The Flat vs List interlude}
1564
1669
The project produced an Operating System that can be deployed on real hardware and can be used in the day to day life of users. Although the number of user-space programs are limited, this was always out of the scope of the project.
1566
With further time and resources, a focus would be put on creating a larger set of builtin programs and creating a network interface for connecting to the internet.
1568
Throughout the project I have gained a lot of knowledge about how computers function and how common structures and procedures are employed in modern operating systems. Furthermore I have gathered experience in using the C language to create powerful, reliable code.
1671
The system successfully achieves fair sharing of all incorporated hardware resources and acts as a platform under which program developers could produce arbitrary complex programs.
1673
With further time and resources, a focus would be put on creating a larger set of built-in programs, for example some more playable games, a more sophisticated file editor, and some presentation software.
1675
Along side this creating a network interface for connecting to the Internet would vastly improve the utility of the system.
1677
Throughout the project I have gained a lot of knowledge about how computers function and how common structures and procedures are employed in Modern Operating Systems. Furthermore I have gathered experience in using the C language to create powerful, reliable code.
1680
1785
\begin{itemize}
1681
1786
\item Scheduler now reuses old PID's
1682
1787
\item Created much better notes program with multi line editing capabilities.
1683
\item Added cpu time metric for all processes.
1788
\item Added CPU time metric for all processes.
1684
1789
\item Created `ls' and `less' programs
1685
1790
\item Improved processes program.
1686
\item Added better testing for memory manager and file sytem.
1791
\item Added better testing for memory manager and file system.
1687
1792
\item Fixed many misc bugs.