HINTS on Project 4: Scheduler - MUFiX
For long-running user processes to test with, you might want to use a simple counting program to consume CPU while you watch your queues.
There is a great one posted here
and onother here is another on here . Or write one yourself. Login to Minix as root.
Open another virtual terminal in Minix (Alt F1) (Alt F2) (Alt F3), login as your user, and run the counter programs in the others, maybe compile them twice and
call them counter1 counter2 or something.
- ls -l /boot/image
You names may look like this (think of a naming scheme):
3.1.4ar09 3.1.4ar10 3.1.4ar11 3.1.4ar12
Where 3.1.4 is the MINIX version, and ar10, ar11, and ar12 are the latest kernel builds created by make install.
When you boot, it boots from here: /dev/c0d0p0s0:/boot/image/3.1.4arX, where it loads the latest kernel image. In my case it would load 3.1.4ar12 on boot.
A side note: c0d0p0s0
- c = channel
- d = device (your hard disk probably)
- p = partition
- s = slice
- /dev/c0d0p0s0 /
- /dev/c0d0p0s1 /home
- /dev/c0d0p0s2 /usr
- /dev/c0d0p0s3 swap
- Take a VMware snapshot of your current system.
- The reason for this is so if you break your kernel, you can roll back/restore to a previous kernel image that works, then fix your files and rebuild a new kernel.
- ls -l /boot/image
- Write down the latest number for reference.
- Change something in /usr/src/kernel/proc.c and maybe proc.h
- cd /usr/src/kernel, make clean, make, takes a few seconds.
- cd /usr/src, make install, takes a few minutes the first time.
- Check for your newly created boot image (a higher number should be there now):
- ls -l /boot/image
- shutdown
- boot
- Or you can use "shutdown -r" for reboot; or you can use VMware tools->reset if you cannot type "boot" at the c0d0p0s0> prompt.
- cd /usr/src/tools, make clean, make install
- cd /usr/src/commands/simple, make clean, make install
Depending on the hardware, structures sometimes require byte alignment. So they will usually be aligned on 4 byte boundaries. If you add an int to the proc struct in proc.h, that should be fine. If you add a char, the compiler will probably add extra "padding" of 3 more bytes (chars), or you can just at 3 extra chars called something like pad1 pad2 pad3 yourself. If you look at the proc struct you will see there are 4 chars declared in a row there, probably for this reason. And using 4 ints (4*4 bytes) would have wasted space, so they used 4 chars (4*1 byte). See page 254 and also page 252 here for a reference on that. You should probably just add your variables to the end of the proc struct, and you may not even need to pad them to 4 byte boundaries, but its a good idea.
You can use kprintf in the kernel. This is the kernel version of printf, and the syntax is the same. Reference kernel/kprintf.c
But you should not or cannot use/print floats
in the kernel. They can a long time for calculations, and they take some work to print. That could slow things down in your kernel.
To see messages in the kernel, they may print to the root's login terminal, or more correctly you can look at the sys messages:
- less /var/log/messages; type "G" to take you to the end.
- less /var/log/messages; type "F" to take you to the end and print new ones as they arrive.
- tail -f var/log/messages; will print out the last 10 lines and then any new ones as they arrive.