Context Switches on Ubuntu

Posted to linux/ubuntu on 2005-12-07 14:08:00

After trying a new motherboard and all that jazz to get my HDTV tuner card working properly I decided to try a new operating system. The thing that prompted this was the notice that some people thought it might be a buffer related issue that was causing some of the reception problems with the card. I also noticed that my system was consistently above 2000 context switches a second even when idle. There was usually around 1100 interrupts a second. I compared this to my RHEL AS box which was around 30/s when idle and running a lot more stuff.

So, today I set out to test this theory some. I dropped in a FC4 x86_64 dvd and installed it on a blank partition on my hard disk. Sure enough, preliminary tests indicate that I'm not loosing data and reception remains clear even when I'm under heavy IO load, such as copying a file over.

So here's my theory. Ubuntu uses a kernel that switches tasks more often to create a more interactive computing experience. However, for devices that produce large amounts of streaming bandwidth, such as HDTV tuner cards (and to a lesser degree SDTV tuner cards), the tasks switch too fast and the buffers never can be completely emptied. By switching to a higher minimum time slice the processor has enough time to empty out the buffers.

Now, the question is this: is there a simple way to change the minimum time slice for tasks under Ubuntu? I remember seeing something where I could set the timer at 10, 100, or 1000 and seeing that it was set to 1000, but I can't find it in the kernel configuration anymore.

Anyway, if you're having HDTV reception problems, I strongly suggest looking at this as an issue. I'm not 100% certain, but the preliminary tests are good. Unfortunately, I can't do the full battery yet because I don't have time and I don't even have video working on MythTV box under Fedora.


Loki Games Under Ubuntu : Alpha Centauri

Posted to linux/ubuntu on 2005-03-07 17:25:00

It's spring break so I decided I would play a few video games. I've got a bunch of the old Linux ports of games from LokiGames (which went bankrupt in a mess of supposed lies and missed payments in January, 2002). Unfortunately, these games need some work to function in Linux. Well, at least the ones that I've tried.

For Alpha Centauri, you should first go and fetch the patch for SMAC. The updates can be found at sunsite.dk. Go and download that. Also, go and download the updated version of loki_patch from icculus. Now, install the game as you would normally. The install worked just fine under my version of Ubuntu (Warty, aka 4.10).

The tricky part comes with patching Alpha Centauri. Running the patch generates the following output:

Verifying archive integrity...OK
Uncompressing Sid Meier's Alpha Centauri 6.0a Update...................
./update.sh: line 60: 11336 Segmentation fault      loki_patch --verify patch.dat
The program returned an error code (1)

This clearly isn't right. So instead of running the patch normally, we've got to do a bit of work. Instead, run the patch with sh ./smac-6.0a-x86.run --keep, this will preserve the unarchived files in a directory called smac-6.0a-x86. Copy the new version of loki_patch to smac-6.0a-x86/bin/Linux/x86/loki_patch. Then go into the directory and run update.sh.

So now we've got a nice updated version of Alpha Centauri, but it still wasn't spitting out sound on my version of Ubuntu (I've mangled some stuff with regards to ALSA and ESD. Also, I've read that there are some other issues with kernel versions. To fix this I created a little script and use this to run SMAC.

#!/bin/sh
LD_ASSUME_KERNEL=2.4.6 SDL_AUDIODRIVER=esd /usr/local/games/smac/smacpack $*

It may be possible to do other fun stuff using the other SDL environment variables. As a side note, I could not get the dynamic version to function properly, which is bummer because it means that I can't really update the libraries and try other fun stuff with them.

As I play with other old games I'll post updates on how to get them going in the weblog.