Tagged: Operating Systems
A GUI for Metapost?
I have sort-of abandoned my Apple Air Book for serious work this last week – going back to a 2008/9 Toshiba laptop (another Morgan Computers purchase) running Linux.
The Apple is a lovely device to travel with and is beautiful, if extremely expensive, device with which to browse the web, but a decade of conditioning to Linux and its command-line power and orthogonal tool set means I am much happier even with a slower machine when it comes to doing things like drawing figures with Metapost.
But having extolled the power of the command line I am wondering whether I should build a GUI for Metapost – essentially an editor panel coupled with a EPS display panel.
Metapost users seem thin on the ground – though maybe that is because a GUI tool doesn’t exist – but anyone who does use it care to comment?
Related articles
- Embedded domain specific language (haskell.org)
- Weekend Project: Linux For Beginners (lxer.com)
- Why Linux May Be Better For You Than What You’re Using Now (tuts.pinehead.tv)
- I Raised My Kids On the Command Line…and They Love It (lifehacker.com)
- fr 0.99b (pypi.python.org)
- Linux Command Line & Bash Shortcuts (lxer.com)
- A Linux Game Changer? (blogs.gnome.org)
The problem with Apple kit (part one?)
Last September I joined a startup, Centreground Political Communications and, like my three fellow employees, have been using Apple equipment more or less since then.
It is good quality kit, focused on (typical) user experience: like Windows done right. And, yes, as a Unix/Linux person I also get a bash shell and access to forty years of engineering excellence.
But it is difficult not to see the faults also:
- The one button mouse – a legacy of the 1980s and one that Apple must recognise is a poor one (why else have all those Ctrl dependent commands?
- The emphasis of design over function – no ethernet port, and a wireless performance massively below even the least powerful IBM compatible
- Audio that works out of the box – if you can ever hear it
Working on filesystem code
Nearly a decade ago I wrote a crude, but working, filesystem for the Sega Dreamcast VMU on Linux. I then put ported a very simple web server to the Dreamcast and got the whole thing on Slashdot.
I never managed to get the thing into mainline – indeed the battering I got last time I tried, in 2009, more or less made me give up writing anything for the kernel and the Dreamcast was put away.
I am not pretending my code was pretty or even particularly good but it is no wonder people get put off from contributing when you get pig ignorant comments like these:
Everything about the on-disk format is tied to the VMU. Until that sinks in, don’t bother sending me email, thanks.
This was someone, who ought to have known better, claiming that it was not possible to have a free standing filesystem for this at all – though they were making their, incorrect, claim in the manner seen all too frequently on the Linux Kernel Mailing List.
No comments. Really. There must be some limits on the language one is willing to use on public maillist, after all.
As you can tell this person – a top flight Linux hacker – did not like my code. And, looking back, I can hardly blame him, it was pretty ugly. But as a help to fix it this is of next to no use – and only serves to demotivate. Nasty computer scientists, again.
Ok, so I have got that off my chest. And I am once more placing myself in the firing line.
The filesystem code, a work in progress (so check where the code has got to once you click the link), can be found here. A filesystem that you should be able to mount under loopback, can be found here. All testers welcomed with open arms.
Related articles
- Watch your back, Dreamcast VMU, here comes the Turbofire EVO (joystiq.com)
- Fedora Aims To Simplify Linux Filesystem (linux.slashdot.org)
- Fedora Goes Against the Linux Standard Base, Restructures the Filesystem (techie-buzz.com)
- Peter Moore: “I didn’t kill the Dreamcast” (thesegasource.wordpress.com)
The cost of soft/minor faults
Here is a complete graph of the memory use and fault count for a run of ls -lia.

As you can see there are only soft/minor faults here – as one would expect (this was a machine with a lot of memory), as the C library provides the ls function and it will be loaded in memory (presumably the filesystem information was also in memory).
But there are a lot of soft faults – and these too have a cost, even if nothing like the cost of a hard fault. For a start each soft page fault almost certainly indicates a miss in the processor cache.
The paper linked here also gives a lot of information about Linux’s generation of soft/minor faults and their performance impact – it seems that the kernel is designed to deliver system wide flexibility at the expense of performance.
Related articles
- Hard faults and soft faults in the real world (cartesianproduct.wordpress.com)
- Profile your applications using the Linux perf tools (baptiste-wicht.com)
- Hello from a libc-free world (blogs.oracle.com)
- Using the newLISP FFI | Artful Code (artfulcode.net)
- Comments about the $200,000 BlueHat prize (erratasec.blogspot.com)
- Library Interface Versioning in Solaris and Linux (usenix.org)
- Understanding Virtual Memory (ualberta.ca)
- Tiago Hillebrandt: Installing Kernel 3.0 via PPA on Ubuntu “11.04″ Natty Narwhal (tiagohillebrandt.eti.br)
- What is Slackware Linux? (diwt.wordpress.com)
- Advanced Linux Memory Allocation (linuxjournal.com)
Counting soft and hard faults
When a running program references a page of memory that is not mapped into its address space the operating system throws a “page fault” – calling some kernel code to ensure that the page is loaded and mapped, or if the address referenced is not legal, that an appropriate error (a seg fault on x86) is signalled and the program’s execution stopped.
If the address is ‘legal’ then two types of fault exist – a ‘hard’ fault where the missing memory (eg some code) has to be loaded from disk or a ‘soft’ fault where the missing page is already in memory (typically because it is in a shared library and being used elsewhere) and so all that has to happen is for the page to be mapped into the address space of the executing program.
(The above is all a simplification, but I hope it is clear enough.)
Soft faults, as you might expect are handled much faster than hard faults – as disk access is generally many orders of magnitude slower than memory access.
Memory management and paging policies are generally designed to minimise the number of faults, especially hard faults.
So – what is the ratio of hard and soft faults? I have further extended the valext program I wrote for my MSc project to count just that – and it seems that on a loaded Linux system soft faults are generally an order of magnitude more common than hard faults even when launching a new program form ‘scratch’ (eg I am seeking to run an instance of ‘audacity’ under valext – and after executing 326,000 instructions there have been 274 soft faults and 37 hard faults).
That is good, of course, because it makes for faster, more efficient computing. But it also means that further optimising the paging policy of Linux is tough – hard faults take time so you can run a lot of optimising code and hope to have a better performance if you cut the number of hard faults even only slightly. But if soft faults out number hard faults by 10 to 1 then running a lot of extra code to cut the number of faults may not be so beneficial.
(You can download valext at github – here NB: right now this extra feature is in the ‘faultcount’ branch – it will be merged into master in due course.)
Related articles
- Some thoughts on the Linux page cache (cartesianproduct.wordpress.com)
- Dovecot v2.1+ Statistics (technology.mattrude.com)
- Android upgraded to be more resistant to hack attacks (go.theregister.com)
- Position Indepentent Code (PIC) in shared libraries (eli.thegreenplace.net)
- Is your site loading slowly? It may not be your fault. (thekencook.com)
- Powershell Process Explorer (gunnalag.wordpress.com)
Best book on Linux kernel internals
Write an MSc project report means having to read a lot of source code and constantly referring to texts in the hope that they will make things clearer.
I have three books on the kernel – there are obviously others, but I think two of these three will be familiar to most kernel hackers – but it is the third that I rate most highly.

Understanding the Linux Kernel: for many this must feel like the standard text on the kernel – it’s published by O’Reilly, so (my experience with their XML Pocket Reference not withstanding) will be good, it’s well printed and readable and it is, after all, the third edition of a book your forefathers used. But the problem is, it is also now six years old and a lot has happened since then. I well remember going into Foyles in the autumn of 2005 and seeing it newly minted on the shelves. For a long time it could hide behind the fact that the kernel was still in the 2.6 series, but even that protection is gone. Verdict: Venerable but getting close to past it.
Linux Kernel Development: the previous, second, edition of this book was a fantastic introduction to how the kernel worked and was written in a slightly whimsical tone which made it easier to read. It is rare that one can read a computer book like a novel, starting from the first page and going on to the end, but you could with that. Sadly someone seems to have got to Robert Love (who, from personal experience I know to be a great guy) and presumably told him he had to be more serious if he wanted his book to be a set text for CS courses. The problem is that the book now falls between two stools – somewhere between a solid but broad introduction to how the kernel works and a guide to writing kernel code. Unfortunately, it does not quite hit either target. That said, it is still worth having. Verdict: Good, but where did the magic go?
Professional Linux Kernel Architecture : unfortunately, everything about the Wrox brand suggests “cheap and nasty”, which is a real pity, as this book is the best of the bunch. Admittedly it would not, as Robert Love’s book, be at all suitable as a primer for operating system study – it is far too big and detailed for that. But if you are looking for an up to date (or reasonably so, anyway) helpmate for actually patching the kernel, then this seems to be the best choice. Sadly the cheap and nasty side does creap through on occasion with bad editing/translation, but it’s not enough to stop me from recommending it. Verdict: this one’s a keeper, for now any way.
Related articles
- Linux OS developers breached by trojan (go.theregister.com)
- * Urgent Linux Kernal/ internal for Aricent-Chennai (referaljobs.wordpress.com)
In your face, fan bois
There is something very annoying about Apple users: they pay twice as much as the rest of us for stuff and then think that they are the clever and cool ones. How does that work?
Well, here’s some bad news for them: their browser is almost certainly broken.
If you look at the graphs on this post, you can see that Safari seems to get worse with every iteration – the opposite to the way Internet Explorer and Firefox are going.
Ha ha.
That is all.
Related articles
- The Surprising Worst Browser (saucelabs.com)
- Apple OS X Lion Brings Host of Security Updates to Safari (readwriteweb.com)
- Safari issues (ealnet2010a.wordpress.com)
Exams are over, project remains
Today saw my last exam for the MSc, though I still have to complete the project.
So, lots of posts about Linux page management to follow – I hope.
Related articles
- What’s next? (cartesianproduct.wordpress.com)
- “Analyzing Computer System Performance with Perl::PDQ” (cartesianproduct.wordpress.com)
- Exams (nannanoergaard.wordpress.com)
Did not quite waste the whole weekend
I vowed not to write about politics here, so I won’t. But the Irish election proved an exciting distraction all weekend. Still, I did manage to get somethings done:
- Fitted a new graphics card on the machine I am using now (the previous one seemed to simply die when I tried to access the “Power Mizer” facilities on the card – Linux users of the nvidia proprietary drivers be warned;
- Fitted a new heat sink on my kids’ Linux box – they will no longer have the excuse they have to use this (my) computer because theirs has died from overheating (plus they have about 5000 more MIPS on their machine anyway);
- Wrote to the users of the Inkling prediction market I had started on Vladimir Romanov’s P=NP proposal to tell them it was dead (for now). I doubt many were surprised – the market rated the chances of his “proof” being correct as 0.09% when I cashed it out.
- Started reading Alone in Berlin
- And last, but by no means least, actually completed a draft of my MSc proposal. I’ll have to read through the text looking for spelling errors and fix up all the references (I discovered the ability to import from BibTeX via uses of Google Scholar this weekend so no more typing by hand).
I am really pleased about that last one. The Irish election results weren’t so bad either.
Related Articles
- No proof of P=NP after all (yet?) (cartesianproduct.wordpress.com)
- The opposite of science, but could be fun (cartesianproduct.wordpress.com)
- Polynomial Time Code For 3-SAT Released, P==NP (science.slashdot.org)
- Rediscovering enthusiasm (cartesianproduct.wordpress.com)
Slow progress on the project proposal
I have been making slow progress on my project proposal – some times it has felt like a mirage: the further I go the further away the real target seems to be.
But I am getting there – though I seem to have written five pages of dense type explaining how Linux paging developed and works without actually describing any problems or what I intend to do about them.
Well, the plan now – and I am writing this down as an aide memoire/encouragement to actually do it is to move on from where I am now – describing the 2Q-like LRU lists in the Linux kernel, to some of the problems, describing the alternative “working set” approach (eg as used in Windows NT and before than VMS) and then some of the strategies and tactics that could be used in Linux to apply it.
Related Articles
- If writing the MSc project proposal is this hard… (cartesianproduct.wordpress.com)
- imabonehead: linux kernel monkey log: How not to piss off a kernel subsystem maintainer – part 5 (kroah.com)
- Linux.fm is an online radio station that broadcasts the Linux kernel (downloadsquad.switched.com)

