Me, Operating Systems, Technology, Sun Microsystems and Stuff!

My Crash - Good news at last!

December 28th, 2007 Michael Clarke

As many of you will know, in June 2007 I was unfortunate enough to have a quite bad car crash. We were on our way to Go Karting as a end of exams trip and a guy in a red Fiesta drifted across the road and hit my car head on at a combined speed of about 100MPH. Fortunately everyone was (is now) okay from the accident. This accident in turn caused a smaller shunt further down the road. I promised in my old blog that I’d put up some photos of my car after the incident, however I never did - so I’ve included them now.

My Car Crash My Car Crash My Car Crash

Ever since then there have been legal battles between a whole host of people who all claimed that it wasn’t their fault. At the same time, the police investigation (which had six months allowance to be concluded) was crawling along. At the end of November (26th to be precise) I was informed at last that the guy in the red Fiesta was to be taken to court on the charge of ‘driving without due care and attention’.

This court hearing took place on the 19th December at 9.30am at Aberystwyth Magistrates Court and I’ve finally heard from the Police that he pleaded guilty! This is excellent news as it now means two things:

  • His claim that I was the cause of the accident to his insurance company is invalid (otherwise why would be plead guilty?)
  • My insurance company will finally pay out my excess and give me back my no claims.

Overall a pretty good day.

OS Development: Where to start?

December 27th, 2007 Michael Clarke

As most people who read this blog will know I’m currently developing a small 32Bit Multi-tasking Operating System called ‘MouthOS’. I figured that I’d start sharing my thoughts and ideas of the development with you all so that, should you be a fool like me, you can write your own OS!

The hardest part of writing an Operating System is where to start! Many people will say ’start wherever you like’. Others will give you warnings about trying to develop ‘Graphical User Interfaces’ straight away. Others will suggest that you do a lot of reading of books relating to Operating System design theory. This is all good advice, and whilst I don’t pretend to be an expert, in my opinion there are three even more important things to consider when starting to develop an Operating System:

  1. What do you want your Operating System to achieve? Many will say be realistic here - don’t be thinking graphical user interfaces and to a certain extent they are correct. However, if you do want to have a graphical user interface this will effect your initial development - you will have to think about interrupts etc. Also this will affect your architecture - is your OS for a washing machine or is it for a fully blown desktop computer?
  2. This brings me onto the next thing - do you know the architecture that you’re going to be developing for? This means understanding what the registers do on your chosen CPU, how the CPU deals with interrupts, what extra features the CPU may or may not have, how the CPU starts execution (where does it get its first instruction from?), how much RAM can it address, and also knowing the assembly language for your chosen architecture.
  3. Once you know your architecture this leads to my final question - what language are you going to develop in? Pure assembly, C, Java, Python? If you’re planning on using Java or Python (or any other interpreted language) you’re going to have to go back to the drawing board - it simply won’t work.

Once you’re comfortable with what your OS is going to achieve, what language its going to be written in, and what it will run on you can start with the boot-loader. In x86 the boot-loader takes over from BIOS. In SPARC the boot-loader takes over from OBP etc. Boot-loaders can be as simple or as complex as you like.

In x86 (as MouthOS is coded in) your boot-loader could directly start calling kernel code, or it could setup the environment, for example setting up the GDT (Global Descriptor Table), IDT (Interrupt Descriptor Table), enable the A20 line and entering into 32Bit Protected Mode. This really depends on what you want your OS to do. If it’s just print some text on screen then there is little point with memory management and 32Bit instructions. However, if you’re planning on having graphics, multiple applications, and if you want to be able to address more than 65K of memory then 32Bit (or even 64Bit) is the way to go. There is loads of information available on the Internet relating to boot-loaders. However, if you’re struggling to find it a good place to start is the wiki and forums at OSDev.Org.

Personally I decided, after the second write of MouthOS, that I was going to use GRUB as my boot-loader. Using GRUB provided a nice way to get into my kernel as GRUB deals with all the above mentioned tasks such as enabling the A20 line, setting up the GDT, getting into 32Bit Protected Mode etc - in essence it puts the system into a known state ready for the kernel. However, even if you’re going to use GRUB at some point (and best sooner than later) you need to re-write the GDT, IDT etc. The reason for this is that you don’t know what GRUB has used for these values and so you could have various things such as users applications overwriting your kernel etc.

This is where I’m going to leave it for now. However, in my next few posts relating to OS development I plan to go over some x86 specific questions like how to implement simple putchar, puts, memcpy functions for your C library. I’ll also cover some other things that you, as budding OS developers, should know - such as how paging and virtual memory work, and where to being when writing a scheduler.

A very (slightly late) Merry Christmas…

December 26th, 2007 Michael Clarke

I had planned to write a entry yesterday - however in the excitement of Christmas I’m afraid I hardly touched my computer. As such I want to wish you all a slightly late Merry Christmas :)

I hope everyone had a great day and that Santa brought everything you wanted - and some more! Enjoy the last few days of 2007 and I wish you all a happy and prosperous 2008.

Merry Christmas and a Happy New Year.

equery - a tool I didn’t know about…

December 23rd, 2007 Michael Clarke

As I was browsing the Gentoo forums earlier today I found a tool that I’ve not used before which looks really useful. Quite often I wonder what packages depend on others in the portage tree…. but no longer.

mikes-computer ~ # equery depends graphviz
[ Searching for packages depending on graphviz… ]
app-doc/doxygen-1.5.4 (!nodot? >=media-gfx/graphviz-2.6)
media-gfx/imagemagick-6.3.5.10 (graphviz? >=media-gfx/graphviz-2.6)
media-libs/libdvbpsi-0.1.5 (doc? media-gfx/graphviz)

Other cool things this little tool does include:

Listing all the packages that own a given file… For example, if I run the following on /usr/bin/gvim I get the following results telling me that the package app-editor/gvim-7.1.164 owns the file /usr/bin/gvim.

mikes-computer ~ # equery belongs /usr/bin/gvim
[ Searching for file(s) /usr/bin/gvim in *… ]
app-editors/gvim-7.1.164 (/usr/bin/gvim)

Another example is if I do a equery belongs on /etc/resolv.conf which doesn’t belong to any particular package:

mikes-computer ~ # equery belongs /etc/resolv.conf
[ Searching for file(s) /etc/resolv.conf in *… ]

Another useful feature of this tool is the ability to find out what files a package owns….

mikes-computer ~ # equery files gvim
[ Searching for packages matching gvim… ]
* Contents of app-editors/gvim-7.1.164:
/etc
/etc/vim
/etc/vim/gvimrc
/usr
/usr/bin
/usr/bin/eview -> gvim
/usr/bin/evim -> gvim
/usr/bin/gview -> gvim
/usr/bin/gvim
/usr/bin/gvimdiff -> gvim
/usr/bin/rgview -> gvim
/usr/bin/rgvim -> gvim
/usr/share
/usr/share/applications
/usr/share/applications/gvim.desktop
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/gview.1.bz2 -> vim.1.bz2
/usr/share/man/man1/gvim.1.bz2 -> vim.1.bz2
/usr/share/man/man1/gvimdiff.1.bz2 -> vimdiff.1.bz2
/usr/share/pixmaps
/usr/share/pixmaps/gvim.xpm

I have to admit that I’ve been most impressed with this tool. It can also do a few other things such as listing all the packages with a given use flag:

mikes-computer ~ # equery hasuse mmx
[ Searching for USE flag mmx in all categories among: ]
 * installed packages
[I–] [ ~] net-misc/asterisk-1.2.21.1-r1 (0)
[I–] [ ~] media-sound/mpg123-1.0_rc2 (0)
[I–] [ ~] media-video/ffmpeg-0.4.9_p20070616-r2 (0)
[I–] [ ~] media-video/mplayer-1.0_rc2_p24929 (0)
[I–] [ ~] media-gfx/inkscape-0.45.1-r1 (0)
[I–] [ ~] media-gfx/gimp-2.4.2 (2)
[I–] [  ] media-tv/xawtv-3.95-r1 (0)

Overall this is a really great tool, and if you don’t have it then you can get it by emerging the gentoolkit…. which I found out by:

mikes-computer ~ # which equery
/usr/bin/equery

mikes-computer ~ # equery belongs /usr/bin/equery
[ Searching for file(s) /usr/bin/equery in *… ]
app-portage/gentoolkit-0.2.4_pre8 (/usr/bin/equery)

Gentoo ‘emerge –deep –newuse –update world’ issues…

December 22nd, 2007 Michael Clarke

Many people tell me that they have issues when running a emerge world on Gentoo to keep their system up to date. I have long argued that the problems are simply because they don’t run the updates regularly enough, and if they were to run updates every week they wouldn’t have these problems.

Unfortunately I have fallen foul of my own advice and haven’t run updates in a couple of weeks. This is now resulting in the following error:

 * ERROR: gnome-extra/evolution-data-server-1.12.2-r1 failed.
 * Call stack:
 *               ebuild.sh, line   46:  Called src_compile
 *             environment, line 3397:  Called gnome2_src_compile
 *             environment, line 2573:  Called die
 * The specific snippet of code:
 *       emake || diefunc “$FUNCNAME” “$LINENO” “$?” “compile failure”
 *  The die message:
 *   compile failure
 *
 * If you need support, post the topmost build error, and the call stack if
 * relevant.
 * A complete build log is located at ‘/var/tmp/portage/gnome-extra/evolution
 * -data-server-1.12.2-r1/temp/build.log’.
 * The ebuild environment file is located at ‘/var/tmp/portage/gnome-extra/
 * evolution-data-server-1.12.2-r1/temp/environment’.

When you hit errors like this there are a number of things that should and can easily be done which 99% of the time will fix the problem. The first is to actually check the logs! The number of times I read the Gentoo forums and people don’t post the true topmost build error is unbelievable. Read the error and read the logs:

 michaelfclarke@mikes-computer ~ $
 cat /var/tmp/portage/gnome-extra/evolution-data-server-1.12.2-r1/temp/build.log \
 | grep -i error
 checking for library containing strerror… none required
  mode, hide preprocessor errors, passes: stubs skels common headers
  mode, hide preprocessor errors, passes: stubs skels common headers
 /bin/sh ../../libtool –tag=CC   –mode=compile x86_64-pc-linux-gnu-gcc
 -DHAVE_CONFIG_H -I. -I../.. -I../.. -I../../src -I../../src -I../../src/libical
 -I../../src/libical -I. -DPACKAGE_DATA_DIR=\”"/usr/share/evolution-data-server-1.12″\”
 -I/usr/include/db4.5  -O2 -pipe -MT icalerror.lo -MD -MP -MF .deps/icalerror.Tpo -c
 -o icalerror.lo icalerror.c
 x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I../.. -I../.. -I../../src -I../../src
 -I../../src/libical -I../../src/libical -I.
 -DPACKAGE_DATA_DIR=\”/usr/share/evolution-data-server-1.12\” -I/usr/include/db4.5
 -O2 -pipe -MT icalerror.lo -MD -MP -MF .deps/icalerror.Tpo -c icalerror.c  -fPIC -DPIC
 -o .libs/icalerror.o
 mv -f .deps/icalerror.Tpo .deps/icalerror.Plo
 /bin/sh ../../libtool –tag=CC   –mode=link x86_64-pc-linux-gnu-gcc  -O2 -pipe
 -version-info 0:0:0 -o libical-evolution.la   icalderivedparameter.lo
 icalderivedproperty.lo icalrestriction.lo icalderivedvalue.lo icalarray.lo icalattach.lo
 icalcomponent.lo icalenums.lo icalerror.lo icalmemory.lo icalmime.lo icalparameter.lo
 icalparser.lo icalproperty.lo icalrecur.lo icaltime.lo icaltz-util.lo icaltimezone.lo
 icalduration.lo icalperiod.lo icaltypes.lo icalvalue.lo pvl.lo sspm.lo vsnprintf.lo
 icallangbind.lo caldate.lo -lpthread
 x86_64-pc-linux-gnu-ar cru .libs/libical-evolution.a .libs/icalderivedparameter.o
 .libs/icalderivedproperty.o .libs/icalrestriction.o .libs/icalderivedvalue.o
 .libs/icalarray.o .libs/icalattach.o .libs/icalcomponent.o .libs/icalenums.o
 .libs/icalerror.o .libs/icalmemory.o .libs/icalmime.o .libs/icalparameter.o
 .libs/icalparser.o .libs/icalproperty.o .libs/icalrecur.o .libs/icaltime.o
 .libs/icaltz-util.o .libs/icaltimezone.o .libs/icalduration.o .libs/icalperiod.o
 .libs/icaltypes.o .libs/icalvalue.o .libs/pvl.o .libs/sspm.o .libs/vsnprintf.o
 .libs/icallangbind.o .libs/caldate.o
 x86_64-pc-linux-gnu-gcc -DHAVE_CONFIG_H -I. -I.. -I. -I.. -I../src -I../src
 -I../src/libical -I../src/libical -I/usr/include/db4.5  -O2 -pipe -MT errors.o
 -MD -MP -MF .deps/errors.Tpo -c -o errors.o errors.c
 mv -f .deps/errors.Tpo .deps/errors.Po
 /bin/sh ../libtool –tag=CC   –mode=link x86_64-pc-linux-gnu-gcc  -O2 -pipe
 -o doesnothing access_components.o
 access_properties_and_parameters.o errors.o main.o parse_text.o
 ../src/libical/libical-evolution.la ../src/libicalss/libicalss-evolution.la
 ../src/libicalvcal/libicalvcal-evolution.la -lpthread
 x86_64-pc-linux-gnu-gcc -O2 -pipe -o doesnothing access_components.o
 access_properties_and_parameters.o errors.o
 main.o parse_text.o  ../src/libical/.libs/libical-evolution.a
 ../src/libicalss/.libs/libicalss-evolution.a
 ../src/libicalvcal/.libs/libicalvcal-evolution.a -lpthread
  mode, hide preprocessor errors, passes: stubs skels common headers
  mode, hide preprocessor errors, passes: stubs skels common headers
 x86_64-pc-linux-gnu-gcc -O2 -pipe -Wall -Wmissing-prototypes -Wno-sign-compare
 -o .libs/create-account create-account.o
 -pthread -Wl,-R/usr/lib64/nspr  ../../libedataserver/.libs/libedataserver-1.2.so
 -L/usr/lib64/nspr -L/usr/lib64/lib
 /usr/lib64/libdb-4.5.so /usr/lib64/libsoup-2.2.so -L/usr/lib64 -lnsl
 /usr/lib64/libgnutls.so /usr/lib64/libtasn1.so
 /usr/lib64/libgcrypt.so /usr/lib64/libgpg-error.so /usr/lib64/libxml2.so -lz
 -lm /usr/lib64/libbonobo-2.so
 /usr/lib64/libbonobo-activation.so /usr/lib64/libORBitCosNaming-2.so
 /usr/lib64/libgconf-2.so /usr/lib64/libORBit-2.so /usr/lib64/libgmodule-2.0.so
 /usr/lib64/libgthread-2.0.so -lrt /usr/lib64/libgobject-2.0.so /usr/lib64/libglib-2.0.so
 -lplds4 -lplc4 -lnspr4 -ldl -lpthread
 x86_64-pc-linux-gnu-gcc -O2 -pipe -Wall -Wmissing-prototypes -Wno-sign-compare
 -o .libs/soap-test soap-test.o -pthread -Wl,-R/usr/lib64/nspr  -L/usr/lib64
 ./.libs/libegroupwise-1.2.so -L/usr/lib64/nspr /usr/lib64/libsoup-2.2.so -lnsl
 /usr/lib64/libgnutls.so /usr/lib64/libtasn1.so /usr/lib64/libgcrypt.so
 /usr/lib64/libgpg-error.so /usr/lib64/libxml2.so -lz -lm /usr/lib64/libbonobo-2.so
 /usr/lib64/libbonobo-activation.so /usr/lib64/libORBitCosNaming-2.so
 /usr/lib64/libgconf-2.so /usr/lib64/libORBit-2.so /usr/lib64/libgmodule-2.0.so
 /usr/lib64/libgthread-2.0.so -lrt /usr/lib64/libgobject-2.0.so /usr/lib64/libglib-2.0.so
 -lplds4 -lplc4 -lnspr4 -ldl -lpthread
 make[4]: *** [create-account] Error 1
 make[4]: *** [soap-test] Error 1
 make[3]: *** [all] Error 2
 make[2]: *** [all-recursive] Error 1
 make[1]: *** [all-recursive] Error 1
 make: *** [all] Error 2
 * ERROR: gnome-extra/evolution-data-server-1.12.2-r1 failed.
 * If you need support, post the topmost build error, and the call stack if relevant.
 michaelfclarke@mikes-computer ~ $

Reading the above nothing stood out that much so I decided to do a grep for warning instead…

 michaelfclarke@mikes-computer ~ $
 cat /var/tmp/portage/gnome-extra/evolution-data-server-1.12.2-r1/temp/build.log \
 |grep -i warning
 configure: WARNING: krb5 support disabled
 checking what warning flags to pass to the C compiler… -Wall -W missing-prototypes
 e-data-server-module.c:86: warning: dereferencing type-punned pointer will break strict-aliasing rules
 e-data-server-module.c:89: warning: dereferencing type-punned pointer will break strict-aliasing rules
 e-data-server-module.c:92: warning: dereferencing type-punned pointer will break strict-aliasing rules
 broken-date-parser.c:125: warning: pointer targets in assignment differ in signedness
 …
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libgnutls.so.13,
 needed by /usr/lib64/libsoup-2.2.so, not found (try using -rpath or -rpath-link)

Ah! The last line of the output seemed to be the problem. My first idea was to simply create a symlink and see what happens:

  ln -s /usr/lib64/libgnutls.so.26 /usr/lib64/libgnutls.so.13

This failed to work. Instead I then tried to re-emerge libsoup. This worked and my original emerge then proceeded with no errors :)

>>> /usr/share/doc/evolution-data-server-1.12.2-r1/TODO.bz2
 * Installing GNOME 2 GConf schemas
 * Reloading GConf schemas …                                          [ ok ]
 * Updating desktop mime database …
 * Updating shared mime info database …
 * Updating icons cache …                                             [ ok ]
>>> Regenerating /etc/ld.so.cache…
>>> gnome-extra/evolution-data-server-1.12.2-r1 merged.

>>> No packages selected for removal by clean

The upshot of all this is - keep your system up to date and remember to read the log files.

Hello World!

December 17th, 2007 Michael Clarke

Welcome to my new blog. Previously I was running a very small, and rather unsuccessful blog at http://users.aber.ac.uk/mfc5. However, in light of my adventures at Sun Microsystems, and the fact that I am currently applying for the position of Sun Microsystems Campus Ambassador at Aberystwyth University (which requires me to write a blog) I thought now would be a good time to start up again - properly.

I’ve tried to move a lot of my projects and stuff from my old website to this new one. Over time I hope to move my trac installation from my home server to this server so you can all enjoy the entertaining source code of MouthOS. I hear many of you ponder the name. The origion of the name is due to two reasons:

  • I have acquired the nickname ‘The Mouth’ at work due to the large quantities of food that I am able to consume.
  • MikeOS, as it was originally called, appears to already exist in 16bit format and is for teaching people how to write an operating system.

For most of my posts I expect there to be quite a bit of technical information on whole host of topics, from the Solars and Linux Kernels, and indeed the MouthOS Kernel, to Sun’s newest and latests products and technologies.

In general I hope this blog will be useful to many people technically and will help to make people more aware of Sun Microsystems and their technologies and products.