Random.org

Q1.3: Can I download the generator software and run it on my own computer?

No. It’s not just the software you’d need, but also three radios (or one, at any rate), which must be carefully adjusted to pick up atmospheric noise at the right volume. It’s not completely trivial to set up.

What a pompous ass.  It IS completely trivial to obtain random entropy.  Three radios?  Give me a fecking break.  This guy clearly sees himself as some sort of God of Random.  Evidence suggests otherwise.  A pure random distribution of bits can be found in every single computer in the world via simple and indeed TRIVIAL programming.  All you need do is:

Query RTC, or if there is no RTC in hardware ask the software for an RTC.

Dependant on RTC, read a bit of memory.

Truly random.  100% guaranteed to produce a bit that could be either 1 or 0 and is entirely unpredictable.

Sure, it requires kernel-level code, and sure it’s a tiny bit predictable, but if you think that is any less random than using atmospheric noise, you’re in for a shocking treat sonny.  Randomness is EVERYWHERE.  Not just at random.org.

Christ, it’s like this guy’s literally walked out of some kind of weird-ass steampunk machine and said “WOW I SEE RANDOM”.

 

EDIT: In the clear light of day, one obvious flaw is apparent; the procedure for grabbing random entropy I outlined would give a tendency towards zero.  However, it is indeed entirely trivial to program a RNG (not a PRNG) using hardware available to every computer system on the planet.  Even if you don’t have a Real Time Clock in hardware, you can quite easily program a recursive function whose randomness increases with each recursion:

#define RECURSION 1
#define RECURSION_LEVEL 3
int current_level = 0;
int randomInt(int seed) {
int n = // use inline assembly to fill n with whatever is currently in an arbitrarily chosen register
if(RECURSION && current_level++ <= RECURSION_LEVEL) randomInt(seed);
return seed;
}

Sure it’s messy but it’s a 2 minute proof of concept.

Advertisements

Linux Memory Usage

I recently became concerned about the performance of a particular application (cmatrix on the 1080p screen – it looks beautiful but it’s quite choppy) so I began some investigating and turned up some surprising statistics.

Uptime: 12:53; of that time, Chrome has been running for most of it and we all know web browsers are notorious for leaking all over your RAM.  Chrome is better than firefox but still pretty leaky.  On Windows XP, it was not uncommon for chrome to be using more than half a GB of RAM.

Now, the surprising thing is, Linux has managed to gobble up all my RAM.  But has it?  If you observe carefully, I’ll explain to you why Linux has -not- gobbled up all of my RAM (despite what ‘top’ tells me) whereas Windows, had it been given the same constraints, would’ve.

The way Linux handles memory usage differs extraordinarily to Windows.  If something leaks in Windows, that RAM is unrecoverable, especially after the application has quit.  However, in Linux, if something leaks, once the application quits, all the memory Linux allocated it is returned to Linux in the form of ‘cached’ memory.  In other words, the memory doesn’t get -deleted-, so if the application comes back and wants it again it’s entitled to the same memory (efficiency++) but if another application wants to use the memory that application -was- using, Linux isn’t gonna say no.  In other words, the memory is still ‘in use’ but it’s also still ‘available’ to new applications who request it.

This presents a difficult situation when you’re measuring RAM usage – do you count the memory as ‘in use’ or as ‘available’?  Well, ‘top’ (and some other tools) see it as ‘in use’, and ‘free’ will also tell you (on the Memory line) that it’s ‘in use’.  However, ‘free’ also has a “-/+ buffers/cache” line which basically takes the buffered memory into account, giving you a fuller picture of how much RAM is available to new applications.  So when you’re measuring RAM, you should use -that- line in your statistics.  Not the above raw figure which counts unreferenced (‘dead’) memory as ‘used’.

Windows XP, on the other hand (but don’t quote me about Vista or 7, I’m unfamiliar with the new kernel but I’m pretty sure it’s the same story in terms of memory allocation), trusts applications to free memory.  If they don’t, Windows will never reclaim the lost memory (not until a reboot anyway).  I’m unsure exactly how the kernel works (only Microsoft know) for this behaviour to be apparent, but I’m not the only one to have made that observation, and I can assure you Windows XP, if left to its own devices, will start swapping out pages like there’s no tomorrow after a couple of days (depending how much RAM you have).

Suffice it to say, if you run WinXP, you’re gonna get slowdown after a while, if you run Linux you can (in theory) continue running it forever.  Note that kernel leaks (which are rare but do happen) and certain other situations (eg video driver bugs) can cause a required reboot due to memory loss, but the situation is far rarer in the Linux world than in Windows.

It is owing mainly to this reason (and the kernel’s greater stability, owing to a better design and fewer crash-inducing bugs) that Linux servers are able to run for…

chris@w1zard:~$ uptime
20:54:58 up 125 days,  4:24,  2 users,  load average: 0.00, 0.00, 0.00

Yup, w1zard (my server) has now been running for 125 days, 4 hours and 24 minutes without a reboot.  The load average statistics being 0.00 is due to the quad core processor; the system doesn’t strain under the minute amount of traffic it’s required to handle (mail only at the moment, too).  I’m very proud.
Have fun hacking!

Ubuntu and HDMI audio

Ok, so I got the video part of the HDMI output working with a couple of deft mouseclicks and the help of my previous workings with nvidia control panel, but when it came to audio…

First off, I go internetting, ask the mighty Google how the heck it is to be done.  I happened upon a ubuntuforums.org post detailing steps to get a GT240 to work, whereupon I hit snag after snag, eventually crippling my entire audio setup.

Eventually, I found that my saving grace was “alsa-utils reset”, but the internet did not tell me this – rather, my brother pointed it out (him being an audiophile and a closet ubuntu geek).  I managed to get my speakers back, and seeing as I wanted to watch a film and had spent a good few hours troubleshooting audio things I decided HDMI audio can wait until it works ‘out of the box’.  Especially considering, as I said earlier, it’s actually a downgrade in speaker quality.

That said, it appears my tweeters have blown (muddy, muffled sounds coming from the hifi at the moment; my brother diagnosed it as blown tweeters, but he didn’t properly examine the patient so I don’t think he’d want to be quoted on that).

Those poised to criticize Ubuntu for not supporting HDMI ought remember that it is an immature technology (HDMI, that is, not Ubuntu) and is steeped in DRM.  Aside from the ethical problems I have with DRM, it also creates lots of technical hassle for projects wishing to use technologies that rely on it.  Especially if the company responsible for the DRM is uncooperative or demands financial recompense for their support in making technology work with it.  The mind boggles at why consumers put up with this kind of treatment, but I guess conglomerates preclude us from having much choice.

Have fun hacking!

Ubuntu dual-screen

Ubuntu doesn’t detect my second monitor automatically, but all it takes is a button ‘detect monitors’.  Windows XP requires multiple reboots and a painfully slow Nvidia Control Panel in order to get anywhere near dual headed graphics.  It also does not provide me with a full 1080p picture (without going too much into the ins and outs of it, Windows XP’s best resolution for the panasonic TV was 1200×950-ish, whereas Ubuntu can give me the full 1920×1080 with a little bit of tweaking).

Admittedly, my experience in the past with Ubuntu has been slightly different when it comes to dual monitors, but for Ubuntu to reach this level of desktop usability within 6 years from their first release (compared to WinXP having 16 years to get from Win 1.0 to WinXP); I’d say that’s pretty gosh-darned impressive.

What’s more, Ubuntu doesn’t route audio through my TV unless I ask it to.  Windows detects the TV’s speakers as an audio device and then PREFERS it to my hifi.  I’d rather have MSN go through the hifi and only films and whatnot that I’m gonna be watching with MSN turned off to go through the TV.  If that, ’cause frankly my hifi’s speakers are gonna be better than my TV’s – they’re just in slightly the wrong place, is all.

Every day I get happier and happier that I’m home.  ❤ ubuntu.  So much.

Have fun hacking!

Change of scenery and new blog title

I will now be posting to linuxwizard.wordpress.com rather than c.pemcjd.me.uk.  c.pemcjd.me.uk will probably die soon, to be replaced with a new domain name, so I thought I’d switch to wordpress.com for domain continuity apart from anything.

Another reason for this change is to become more of a tech blog and less of a personal blog.  Also, because wordpress.com updates itself and provides a bunch of features not available to the downloaded version of wordpress I was using previously.  It’s also free.

And I love the SAAS model.

And it reduces the load on my server (lol, as if).

And stuff.

 

Have fun hacking!

Followup: Installing Ubuntu from Windows

Ok, so I got unetbootin installed and rebooted.  But I’m hit with a Windows error message saying it can’t boot.

I’ve edited boot.ini thusly:

9c9
< F:\ubnldr.mbr="UNetbootin"
---
> multi(0)disk(0)rdisk(0)partition(2)\ubnldr.mbr="UNetbootin"
9c9< F:\ubnldr.mbr="UNetbootin"---> multi(0)disk(0)rdisk(0)partition(2)\ubnldr.mbr="UNetbootin"

This -should- allow me to boot into ubuntu.  Fingers crossed.  Will edit if not.

EDIT1: This did not work.  Windows’ bootloader thought unetbootin was a Windows operating system, and was therefore expecting files which are clearly not present.  I’m therefore re-installing unetbootin in the vain hope that it will work.  Will edit again when it doesn’t.

EDIT2: This did not work.  Windows’ bootloader STILL thinks unetbootin is a Windows operating system despite several variations in my installation procedure.  I think the only way to convince my computer otherwise is to take the decision out of Windows’ hands.  That requires waiting for Mike to wake up and give me a blank CD though (his LiveCD of Ubuntu is 64bit and my processor is somewhat deficient in bits.  It only has 32, bless it…)  Another edit will follow with tales of my success once I have a CD in my hands…

EDIT3: Day 2 of using Ubuntu again and I can honestly say I couldn’t be happier.  Windows XP is probably never going to see the light of day again.  I’m home!!! SO happy!

Installing Ubuntu from Windows

I recently ran into the problem of using wubi.exe (Ubuntu’s Windows installer) to install Ubuntu 10.10 and hitting a “try (hd0,0): EXT2:” hang.  Information on the internet is sporadic and confusing at best so I thought I’d post a run-down of what steps I took, what worked and what didn’t.

Note that this whole procedure would’ve been a lot easier if I had a blank CD or a LiveCD of Ubuntu to hand, but I don’t, so never mind.

Ok, so when I hit the error I gave it time to complete what it was doing, it was definitely hung.  So I rebooted back into Windows and tried a different .iso image.  Same issue.  So I tried a different wubi.exe (specifically, the one on the 10.10 i386 iso rather than the one you get if you choose to download it from ubuntu.com).  Same issue.  At this point I ran around the net in circles for about an hour getting nowhere fast but eventually stumbling upon some people reporting the issue affecting EasyBCD.  So I looked into what exactly EasyBCD was, it turns out it’s a way to modify the Windows Vista/7 bootloader.  Since the SP3 bootloader is nigh-identical to the Vista/7 one, I thought EasyBCD might help.  Unfortunately, it’s only superficially identical, and despite following a “howto use EasyBCD on Windows XP” tutorial, I managed to completely remove the Windows XP bootloader menu, replacing it with a black screen that flashes for a second then boots into windows.  Great.  So now I can’t even -try- to boot wubi.

It was at this point I hit the ‘net again, and after another hour or two of circular google-forum-google work I eventually hit upon “Unetbootin”.  I knew of Unetbootin before but only very vaguely, had once used it to try out a few OSes.  It turns out that Unetbootin can mimick wubi, almost, but in a much more sane way.  What Unetbootin does is perform a ‘frugal install’, in other words using your hard disk as a LiveCD.  Sort of a LiveHDD idea.  Perfect!  Once you’re in the Live environment, performing an install to an already-prepped Ubuntu partition (which I just so happen to have) is trivial.  I’ll post a follow-up detailing my success with this (it’s currently halfway through installing).

Check back later!