Submit: Turn in your source code using the
turnin command on the lab machines. Please turn in only the files
system/create.c, system/ctxsw.S, and system/testcases.c .
Work should be completed in pairs. Be certain to include both
names in the comment block at the top of all source code files. It
would be courteous to confirm with your partner when submitting the
assignment.
Preparation
First, make a copy of your Project 4 directory:
cp -R xinu-hw4 xinu-hw5
Then, untar the new project files on top of it:
tar xvzf ~brylow/os/Projects/xinu-hw5.tgz
New files:
system/initialize.c | | Updated initialization for Project 5. |
system/main.c | | A "main program" for testing scheduling. |
system/queue.c | | An implementation of the queue data structure. |
system/create.c | | A partial function for creating a new process. |
system/ctxsw.S | | An incomplete assembly routine for switching process contexts. |
system/ready.c | | An complete function for adding a process to the ready queue. |
include/proc.h | | Process table declarations and constants. |
include/queue.h | | Process queue entries. |
include/kernel.h | | Definitions of XINU standard function prototypes such as kprintf(). |
include/xinu.h | | Includes all necessary XINU header files. |
include/stddef.h | | Various standard XINU type definitions. |
compile/Makefile | | Updated rules for compiling XINU. |
The create() and ctxsw() functions are incomplete and
must be filled in.
The major locations are marked with "// TODO... ."
File system/testcases.c contains code to test your create() and ctxsw()
with three processes, each of which prints a process ID and then yields.
Once your creation and context switch functions are working, you will
see these three processes take turns running on multiple cores.
Some Assembly Required
An operating system's context switch function typically must be written in
assembly language because the low level manipulations it performs are not
modeled well in higher-level languages. If you have not worked in ARM
assembly language before, there are many helpful resources available online.
Despite its low-level nature, a context switch does not require complex
instructions. Our context switch can be completed using only arithmetic
opcodes, and
the load (ldr), store (str), and move (mov) opcodes.
Please refer to ARM Information Center
for a useful explanation of general ARM syntax.
Note: The Raspberry Pi 3 Model B+ is equipped with a ARM Cortex A-53
processor, which implements the ARMv8-A instruction set. While it is 64-bit-capable,
XINU uses its 32-bit instruction set for simplicity.
Testing
The default test case provided with the tarball is necessary, but
not sufficient. Just because it switches between a handful of identical
processes does not guarantee correctness. In embedded systems, details
matter. (A LOT!) Students in previous terms have found that subtle bugs
in this phase of the term project were responsible for nightmares weeks
and months down the line. Test your code thoroughly:
- Processes can be passed an arbitrary number of parameters upon creation;
- Processes should terminate cleanly upon exit;
- Stack pointers and activation records should align properly and
have known contents at critical check points.
- ready(pid_typ pid, bool resch, uint core) is at your disposal for
running your processes. For testing, at first, it is recommened to ready processes only on core 0.
You have a working I/O driver, and a kprintf() function for formatted output.
Use these to explore every aspect of the operating system structures you are
building.
Questions on this project
Photos from 2017:
Photos from the projected screen differ markedly because I am adjusting them to be as readable as I can. I am experimenting/learning image "enhancement" techniques (using Gimp). I am not trying for a photo-realistic image of the screen. Any suggestions you have for making these photos more useful to you are welcome.
Photos from 2012:
|