UpFront

diff -u: What's New in Kernel Development

Zack Brown

Issue #202, February 2011

There's a new dd in town. Specifically, it's ddpt, written by Douglas Gilbert, Mark Knibbs and others. The pt is short for pass through and refers to the SCSI pass through interface that ddpt specializes in. Douglas announced the project and provided the URL: sg.danny.cz/sg/ddpt.html. The original dd tool, on which ddpt is based, is a low-level, super-powered data copier, designed (among other things) to convert data between formats recognized on different architectures.

For those of you who've been missing Jon Masters' kernel podcast, it's back! The feed is at podcasts.jonmasters.org/kernel/kernel.xml, and the transcripts are at www.kernelpodcast.org. It's a tough project, due to the psychotically high volume of mailing-list traffic he needs to cover. He took a break a while back as an alternative to burn-out, and he's now announced that he's back and going at it again. Have fun this time around, Jon!

Linux is famous for its high uptimes. But, nowadays people want to maximize resource usage by cramming lots of KVM instances onto a given hardware system, and they want each virtual machine to have either a high uptime or at least a quick recovery time. Fernando Luis Vazquez Cao and other folks are trying to improve KVM's high-availability powers by triggering a recovery event whenever a KVM instance goes down. It's much more straightforward to do this for a virtual machine than for an actual hardware computer. When a physical computer goes down, it also might bring down whatever triggering mechanism is supposed to start the recovery process. When a virtual machine goes down, there's much less danger that the enclosing process might be damaged, so the trigger always can be initiated.

There's a new IRQ Subsystem maintainer! Or at least, it's the same old guy, but now it's in the MAINTAINERS file. Joe Perches recently posted a patch listing Thomas Gleixner as the IRQ maintainer. This was based on the fact that Thomas submits almost 50% of IRQ patches, while the next highest contributor submitted only 13%. IRQs (interrupt requests) are very quick responses to events on the system. They let you keep browsing the Web while behind the scenes everything keeps going on the way it's supposed to. And, now there's a maintainer for all that.

Miklos Szeredi announced a new union filesystem he'd been working on. Union filesystems are neat, because if you have two different filesystems with a similar directory structure, you can use a union FS to overlay them both on top of each other so they appear to be a single directory tree. File A in /home on one filesystem and file B in /home on the other filesystem, for example, then would appear to be files A and B in /home on a single unified filesystem. There also are various interesting implementation problems, such as what to do if both filesystems have a file A in /home. Which one does the user see? Miklos' union filesystem would assign one filesystem to be the “upper” one, and the other to be the “lower” one. If any files were duplicated across both filesystems, only the one in the “upper” filesystem would be visible to the user. Neil Brown discussed this and more in the documentation he contributed to the project, in response to Miklos' announcement.

Focus on Writing: FocusWriter

Shawn Powers

Issue #202, February 2011

Because you're reading this in a magazine, it's fairly obvious I'm a writer. What might not be obvious, however, is that I'm also easily distrac—LOOK, A PONY! Seriously though, if you do any writing, you've likely discovered that word processors weren't designed for people that need to pump out a specific amount of text in a specific amount of time. There a few features we don't need and really don't want:

  • Formatting, smart quotes, rich text.

  • Any format that is not plain text.

  • Photo insertion.

  • Automatic list formatting.

Those things are great if you're writing a paper for a college professor, or if you're creating a proposal for purchases. Unfortunately, what is a feature for some is a hindrance for others. As a writer, features I want are:

  • A running word count—in publishing, word count is king.

  • A full-screen mode to hide distractions—and ponies.

  • Autosave.

  • A standard and simple file/save interface.

And really, that's it. They may seem like simple things, but it's difficult to find software that meets the bill. A few options are available, but by far, the most usable I've found is FocusWriter. It has all the features I want, and it's small and fast requiring very few libraries to install. My only complaint is there's no option for keeping the menu on the screen. In order to see the menu, you need to mouse-over the top of the window. Yes, I know it's a feature, but it's a feature I'd like to turn off. The flickering menu tends to distract me. You know, like a pony.

Check it out at gottcode.org/focuswriter.

FocusWriter

Non-Linux FOSS

Shawn Powers

Issue #202, February 2011

If you've ever taken notes in Linux, chances are you've at least tried Tomboy. It's installed by default on most systems, and it's a rather impressive application for jotting down quick notes. One of its newer features is the ability to sync notes between computers. One of the benefits of that feature is that the note-syncing works cross-platform! Because there are native versions of Tomboy for both Windows and OS X, syncing between Linux and non-Linux computers should be a breeze.

The syncing feature is relatively new to Tomboy, so it's possible you'll run into a few snafus, but for cross-platform, open-source note-syncing, it's worth the effort. Download installers for all three platforms at projects.gnome.org/tomboy, although if you're running Linux, it's probably already installed.

Maximum Theory with Maxima

Joey Bernard

Issue #202, February 2011

Last month, I explained using Scilab to analyze the results of an experiment. In that specific case, I looked at a pendulum and how it behaved with different lengths and weights. This month, I cover using Maxima to help derive the equations describing the motion of a pendulum.

Maxima is a calculating engine that runs on the console, and several GUI front ends are available for it, such as wxMaxima. Maxima and its GUIs should be available for your distribution; if not, get the source code from the main Web site (maxima.sourceforge.com).

To start Maxima on the command line, type maxima. You should see some licensing information and then a prompt (Figure 1). To get a GUI, run wxmaxima (Figure 2).

Figure 1. Maxima Prompt

Figure 2. wxMaxima GUI

Maxima runs as a continuous session, much like Maple or Mathematica. To end your session and exit the program, execute the quit(); command. Notice that commands within Maxima end with a semicolon. Anyone used to coding in C should be familiar with this. If you end a command with a $ instead, the output from that command won't be displayed.

Sometimes you may run a command in Maxima and not realize how long it will take to finish. If it's taking too long, stop execution by pressing Ctrl-C. Like in bash, Ctrl-C stops execution of the currently running command. Because this is a forced stop, you'll get an error message, but don't worry about following up on it, unless you suspect something deeper is happening.

Maxima also contains help files for all of its built-in functions. To see detailed information about a function, type ? command to see a help page on the given command. For most commands and functions, you'll also get some examples.

When you first start Maxima, the prompt is simply:

(%i1)

Every input line is labeled in a similar fashion, with incrementing numbers. So after the first prompt, the following input prompts would be %i2, %i3 and so on. The output from commands are displayed immediately following the command, labeled with tags of the form %o1, %o2, %o3 and so on. These behave the same as variables in Maxima. This means you can refer to earlier commands or their results simply by using the label. If you wanted to rerun the very first command you ran in this session, simply execute %i1;. There also are shortcuts for the last command and the last result. For the last command, simply type two single quotes (''). For the last computed result, type a single percent sign (%). The percent sign also marks special built-in values—for example, %e (natural log base), %i (square root of -1) or %pi (3.14159...).

Maxima can handle arithmetic very easily. The most common arithmetic operations are:

  • + — addition

  • - — subtraction

  • * — scalar multiplication

  • / — division

  • ^ or ** — exponentiation

  • . — matrix multiplication

  • sqrt(x) — square root of x

You can apply these to both numbers and variables. Arithmetic is done exactly, whenever possible. This means things like fractions are kept as fractions until you explicitly ask for a numeric result. So you see behavior like this:

(%i1) 1/100 + 1/101;
(%o2)             201
                 -----
                 10100

Variables are easy to use in Maxima. They simply are alphanumeric strings. Use the colon character to assign a value to a variable. For example, if you want to find the square of a number, use:

(%i1) x: 2;
(%o1)             2
(%i2) x^2;
(%o2)             4

You also can assign more complex functions to a variable—for example:

(%i3) w: sin(0.5 * %pi);
(%o3)            sin(0.5 %pi)
(%i4) w^2;
(%o4)            sin^2(0.5 %pi)

In certain cases, Maxima leaves results in a partly computed state. If you want to force Maxima to give you a number, add , numer to the end of your command. So, for the above, you would type:

(%i5) %o4, numer;
(%o5)             1

This use of numer will give you 16 significant figures, but Maxima can handle arbitrarily large numbers. The bfloat function converts your result to a numeric representation. The number of significant figures used by bfloat is set by the variable fpprec (the default is 16). As an example of really large numbers, try:

(%i1) %pi;
(%o1)                                 %pi
(%i2) %pi, numer;
(%o2)                          3.141592653589793
(%i3) bfloat(%pi);
(%o3)                         3.141592653589793b0
(%i4) fpprec: 100;
(%o4)                                 100
(%i5) bfloat(%pi);
(%o5) 3.1415926535897932384626433832795028841971693
   ↪9937510582097494459230781640628620899862
   ↪8034825342117068b0

Maxima handles algebra very easily. The expand function can be used to expand a polynomial—for example:

(%i1) (x + 3*y + z)^2;
                                             2
(%o1)                           (z + 3 y + x)
(%i2) expand(%);
                     2                      2            2
   ()               z  + 6 y z + 2 x z + 9 y  + 6 x y + x

You can do a variable replacement very easily with:

(%i3) %o2, x=5/z;
                       2           30 y   25      2
(%o3)                 z  + 6 y z + ---- + -- + 9 y  + 10
                                    z      2
                                          z

If you want to figure out the factors for the above example, use:

(%i4) factor(%);
                                 2             2
                               (z  + 3 y z + 5)
(%o4)                          -----------------
                                       2
                                      z

The last set of algebra functions that you might need are trigexpand and trigreduce. These do the same kind of function as expand and factor. The function trigexpand uses the sum of angles formulas to make the argument of each trigonometric function as simple as possible. trigreduce does the opposite and tries to make the expression such that it is a sum of terms with only one sin or cos function in each term.

Now, you should have enough information to use Maxima and figure out what you should have found last month with the pendulum. The only force that is applied to a pendulum is gravity, constantly trying to pull the pendulum straight down. This is called a restoring force and is:

F = -mg sin(O)

where m is the mass of the pendulum bob, g is the acceleration due to gravity, and O is the angle the string makes with perpendicular pointing straight down. The sin function is a bit difficult to work with, so let's look at how to replace it. If you do a Taylor expansion of sin, you get:

(%i2) taylor(sin(x),[x],0,5);
                                  3    5
                                 x    x
(%o2)/T/                     x - -- + --- + . . .
                                 6    120

From this, you can see that you probably can replace the sin function with O, as long as this angle isn't too big. This will give you:

F = -mgO

If the angle O is measured in radians, it's equal to x/L, where x is the actual amount of the arc that the pendulum bob travels along, and L is the length of the pendulum string. Once you do this, you've essentially minimized the nonlinear part to the point where you can treat the pendulum as a simple harmonic motion, with the force constant of (mg/L). If you plug this in to the equation for harmonic motion, you get the time for an oscillation given by 2*pi*sqrt(L/g). In a Maxima session, this would look like Figure 3. You can see that we get a result from theory that is really close to what we actually measured.

Figure 3. Time for an Oscillation

In the coming months, I'll look at more of Maxima's abilities, including advanced algebra, calculus and even plotting. Until then, go out and do some science of your own.

The MosKeyto's Buzz

Shawn Powers

Issue #202, February 2011

A review of a USB drive might seem like a silly notion, but when the USB drive is barely bigger than the USB port itself, it seems worth mentioning. I recently was sent a LaCie MosKeyto USB drive, and I must admit, it's even smaller than I expected it would be. In fact, the cover to the Flash drive is actually bigger than the drive itself!

Because the drive is so small, it makes sense to keep it on a keychain. Most of my USB drives started with a cap, but after about three or four minutes of use, I would lose them. The LaCie drive has a neat keychain strap that secures both the drive and cap onto your keyring. So, if you're looking for a non-obtrusive USB drive to leave plugged in to your laptop, or if you want a portable Flash drive that won't dominate your keyring, the MosKeyto might be just the device you need. It also comes with some Wuala on-line storage, but really, what's exciting is how small these things are. They must compress the data or something—just teasing, it's obvious they fold the data to make it fit. Visit www.lacie.com/us/products/product.htm?pid=11546 for more info.

Associate Editor Shawn Powers and His MosKeyto

Netflix and Linux, It's a DRM Shame

Shawn Powers

Issue #202, February 2011

By the time this goes to press, the Boxee Box by D-Link will be in the wild. I've written about this little guy before, but one of the exciting and frustrating last-minute announcements is that Netflix would be one of the content partners. When you add the Boxee Box to the Roku devices, and even a few televisions, you have a whole lineup of Linux-powered devices streaming Netflix!

Surely that is reason to celebrate. Unfortunately, it's a bittersweet celebration, because although many Linux-powered devices can indeed stream Netflix content, Linux desktop users still can't stream to their computers. Why, you ask?

Simple: DRM.

In order to approve Netflix streaming in embedded Linux devices, Netflix has included some sort of proprietary video decoder that obviously works under Linux. Why Netflix won't release that proprietary, DRM-laden software to the greater Linux community is a mystery. Is Netflix afraid it will get reverse-engineered so people can watch its streams for free? Well, unfortunately for Netflix, that probably will happen someday. If Netflix would release a proprietary, binary-only player for Linux users, the motivation to reverse-engineer would be close to zero.

So Netflix, do you want to protect your evil DRM? My suggestion is to release your proprietary binary-only software quickly. I warn you, nothing hacks like a spurned geek. Oh, and fellow geeks? Why not drop Netflix PR a note regarding your frustration. The PR page doesn't specifically have a section for DRM complaints, but it seems to me it's a public relations problem: www.netflix.com/ContactPR.

They Said It

It has become appallingly obvious that our technology has exceeded our humanity.

—Albert Einstein

Technology is like a fish. The longer it stays on the shelf, the less desirable it becomes.

—Andrew Heller

The most overlooked advantage of owning computers is that if they foul up there's no law against whacking them around a bit.

—Eric Porterfield

My biggest fear regarding cloud computing is that it sounds disturbingly close to “SkyNet”.

—Shawn Powers

The future masters of technology will have to be light-hearted and intelligent. The machine easily masters the grim and the dumb.

—Marshall McLuhan

LinuxJournal.com

Katherine Druckman

Issue #202, February 2011

As you flip through the awesome articles in this month's Linux Journal, you probably will think a lot about your own personal desktop preferences, your favorite desktop applications, or perhaps some tips and tricks you like to use to make your life a little easier. While you are pondering these things, I'd love for you to consider writing about them for LinuxJournal.com and sharing them with our on-line audience. We always are looking for tips and tricks, how-tos and other articles for our on-line publication, and if you'd like to share your knowledge with our Web readers, please send an e-mail with your idea to info@linuxjournal.com. I'd love to hear your ideas and see your byline on LinuxJournal.com!

Don't forget, there is a lot more great information about desktop Linux at LinuxJournal.com. Visit www.linuxjournal.com/tag/desktop to find more articles to help you get the most out of your Linux machine. See you there!