LJ Archive

UpFront

diff -u: What's New in Kernel Development

Zack Brown

Issue #216, April 2012

Arjan van de Ven recently found a way to reduce boot times on most systems by a staggering amount. Instead of the usual approach, starting each CPU in turn, Arjan's patch starts them all at once. On his system, he achieved a 40% faster bootup with this patch. This also seems to be just the beginning. Arjan has plans to get userspace started up after just the first CPU starts up, while the other CPUs are still pending. This could give the user a usable system extremely quickly. However, as he and Ingo Molnar both agreed, this would involve some highly invasive changes to the kernel that would certainly result in much breakage throughout the entire system. Their plan is to go slowly and carefully, fixing problems as they're revealed, and ultimately achieve massive goodness.

Several kernel developers, including Pavel Emelyanov, Oleg Nesterov and Tejun Heo are working on a way to control the process ID (PID) of a given process. Most of the time the PID is not relevant to ordinary users—what typically matters most is that the process runs correctly. But, sometimes the ability to change the PID can enable really cool features, such as migrating processes cleanly from one computer to another or allowing a debugger to switch cleanly between several saved states of a running process.

Unfortunately, finding the best place in the kernel source tree to provide control over PIDs is not easy. And, Linus Torvalds has said that it's important to keep this kind of feature from running away with itself, adding strange new functionality in places where such things aren't needed and only muddy the interfaces.

Believe it or not, it's official kernel policy to restrict patches to 80 columns of text or less. This ancient requirement dates back to the era of text-mode consoles that were themselves restricted to 80 columns. But there are some places in the kernel source that violate that rule, and a very large number of kernel developers would love to ditch the restriction altogether or at least make it something a bit more palatable, like 100 columns or (for the sake of multiple-of-8-ness) 96 columns.

Folks like Ingo Molnar and Andrew Morton endorsed changing the policy, and a lot people were very pleased. But, apparently Linus Torvalds is dead set against changing it. In his post to the mailing list, he said that yes, some parts of the kernel were exceptions and used more than 80 columns. He also said that it was important to keep those places exceptional, and not get the idea that more and more code on a single line would be a good thing.

So, for now at least, and really probably for a good number of years to come, the 80-column limit on kernel patches remains in effect.

Make TV Awesome with Bluecop

Shawn Powers

Issue #216, April 2012

A few weeks back, I was whining that although Doctor Who was available on Amazon Prime streaming, I didn't have any way to watch it on my television. Thankfully, my friend Richard Servello pointed me to the bluecop repo for XBMC. Not only does bluecop support Amazon Prime streaming, but it also has add-ons for Hulu and countless other network-video-streaming collections.

Now, not only can I take advantage of my Amazon Prime membership on our 55" TV, but also my family can watch clips of The Target Lady on Hulu. I don't think the add-ons in the bluecop repo are endorsed by any of the streaming-media providers, but it seems they pull video only from the Web. If you want to extend your XBMC setup to include a huge selection of streaming media, check out the bluecop repository (code.google.com/p/bluecop-xbmc-repo). Richard, thanks for the tip!

Non-Linux FOSS

Shawn Powers

Issue #216, April 2012

IRC is one of those chat protocols that really lends itself well to the command line. Irssi works very well, and because it runs on a server, all a person needs to use it is a terminal window. For many users, however, a friendly GUI makes the chatting experience a lot nicer. In Linux and Windows, there are many options from which to choose, but in OS X, the options are a little more limited. Thankfully, one of the nicest IRC clients for OS X also happens to be open source!

Colloquy has the familiar look of an OS X program, but it doesn't sacrifice any of the text-based power of IRC. It supports file transfers, notification sounds, and if you read Bill Childer's article “Seamlessly Extending IRC to Mobile Devices” in the March 2012 issue, you'll know it can work with your Irssi install for some really awesome multi-endpoint chatting.

Colloquy is available for OS X, and also for mobile devices. Check it out at www.colloquy.info.

Chemistry the Gromacs Way

Joey Bernard

Issue #216, April 2012

In this article, I'm diving into chemistry again. Many packages, both commercial and open source, are available to make chemistry calculations at the quantum level. The one I cover here is gromacs (www.gromacs.org). It should be available for your distribution via its package manager.

The gromacs package is actually a full complement of small applications to take care of all of the steps from creating the initialization files, to doing the computational run, to doing analysis and visualization of the results. You also may notice more than one version available. For example, Ubuntu has both a single-processor version and an MPI version to do the calculations on a parallel machine. If you have a multicore machine or a cluster of machines at your disposal, this can help speed up your calculations quite a bit.

Before I start, here's a little background as to what types of calculations are possible and what methods gromacs uses. Ideally in computational chemistry, you should be able to take the Schrodinger's equations for the system in question and solve them completely. But, outside of very simple systems of only a few atoms, doing so becomes impossible rather quickly. This means some sort of approximation is required to get a result. In gromacs, the approximation method is molecular dynamics (MD). MD simulations solve Newton's equation for a set of interacting particles to get their trajectories. The total force on a particle from all of the other particles is calculated and then divided by the mass of the particle to get its acceleration. This is calculated for all of the particles, and every one moves according to its acceleration. Then, time is stepped one unit, and the whole thing is calculated again. You can increase the spatial and temporal resolution, at the cost of more computer time, until you get results that are accurate enough for your purposes.

MD simulations have several limitations. The first is that it is a classical simulation. In most cases, this is fine, but there are situations when you need to know the quantum effects of the atoms in your system. The second limitation is that electrons are in their ground state and are treated as if they move instantly to remain in orbit around their atoms. This means you can't model chemical reactions or any other electronic interactions. The next limitation is that long-range interactions are cut off. This becomes a serious issue when dealing with charged particles. The last limitation that I look at here is the fact that periodic boundary conditions are being used to try to simulate bulk systems. This, combined with the cut-off mentioned above, means you can end up with some unphysical results, especially during long runs.

Now that you have some background, how do you actually use gromacs? You need to start with the inputs: the initial position of all the atoms, the initial velocities and the interaction potential describing the forces between all of the atoms. The center of mass of the entire system is usually defined as having zero velocity, meaning there are no external forces on the system. Once this initial data is entered, gromacs needs to calculate the forces, apply these forces to each particle and calculate their new positions. Once they have moved, gromacs needs to recalculate the forces. This is done using the leapfrog algorithm. To get a better feel for what this looks like, let's consider a concrete example: a protein in water.

The first step is to come up with the initialization files needed to do your calculation. This can be done completely from scratch, but in many cases, it isn't necessary. In the case of proteins, there is the Protein Data Bank (PDB), located at www.pdb.org. Make sure the protein structure has the required detail you are looking for in your simulation. You also can load it up in PyMOL and see what it looks like. When you are happy with your selection, you can use it to generate the required initialization files for gromacs with pdb2gmx:

pdb2gmx -f my_protein.pdb -water tip3p

where tip3p is one of the water models that you can select. This command generates several output files, the most important of which are conf.gro, topol.top and posre.itp. At this point, you still haven't added the water to the initialization files. To do so, you first need to define a box to hold the water and the protein. To do that, you would edit the configuration files with the following:

editconf -f conf.gro -bt dodecahedron -d 0.5 -o box.gro

This defines a box with the shape of a dodecahedron and a diameter of 0.5nm. You also can use boxes with cubic or octahedron shapes. Now that you have a box, you can add the water with the command:

genbox -cp box.gro -cs spc216.gro -p topol.top -o solvated.gro

This command takes the box (box.gro) and fills it with water molecules as defined in the file spc216.gro. The -p topol.top option adds this water to the topology of the system. Finally, all of this is written out to the file solvated.gro.

If you tried to run it now, you probably would run into issues because of large forces caused by the introduced water molecules. To deal with that, you can minimize the energy of the system before actually doing any calculations. You can do this by creating a parameter file to define how to do the minimization. For example:

------em.mdp------
integrator   = steep
nsteps       = 200
nstlist      = 10
rlist        = 1.0
coulombtype  = pme
rcoulomb     = 1.0
vdw-type     = cut-off
rvdw         = 1.0
nstenergy    = 10
------------------

In this example, the minimization is being done by steepest-descent, over 200 steps. You can look up the details of all the other options in the gromacs documentation. With this finished, you can do all of the necessary pre-processing with the grompp command:

grompp -f em.mdp -p topol.top -c solvated.gro -o em.tpr

The actual minimization is handled through:

mdrun -v -deffnm em

The prefix em is used for all of the relevant filenames, with different extensions. This makes it easier to do all of the pre-processing and get the initialization steps completed on your desktop, then doing the actual run on a supercomputer.

When you are ready to do the final run, you need to set up a parameter file describing the details. In this example, you could use something like this:

------run.mdp------
integrator   = md
nsteps       = 5000
dt           = 0.002
nstlist      = 10
rlist        = 1.0
coulombtype  = pme
rcoulomb     = 1.0
vdw-type     = cut-off
rvdw         = 1.0
tcoupl       = Berendsen
tc-grps      = protein non-protein
tau-t        = 0.1 0.1
ref-t        = 298 298
nstxout      = 1000
nstvout      = 1000
nstxtcout    = 100
nstenergy    = 100
------------------

With this parameter file, you can do the pre-processing with:

grompp -f run.mdp -p topol.top -c pr.gro -o run.tpr

The actual MD calculation is done with the command:

mdrun -v -deffnm run

Now you can go off and drink a few days' worth of coffee. The actual runtime will depend on how many processors you have to throw at the problem.

Once this run is completed, you still need to analyze it to see what you can learn from it. You can compare the results to experimental results from X-ray structure measurements. You can measure the displacement of the heavy atoms from the X-ray structure with the g_rms program. You can analyze distance and hydrogen bonds with the g_dist and g_hbond programs. You can even make a movie with the trjconv program:

trjconv -s run.gro -f run.xtc -e 2500.0 -o movie.pdb

This will export 2.5ns to a movie of the trajectories. You then can view it using PyMOL.

This short article has provided only the faintest taste of what gromacs can do. I hope it sparks your interest in reading up on it and doing some new and interesting work.

Kill A Watt: Now with Less Math!

Shawn Powers

Issue #216, April 2012

If you're interested in how much energy your electronics use, it's hard to find a device better than a Kill A Watt—except maybe the Kill A Watt EZ! P3 International now offers model P4600, which provides the same features as its predecessor, but it also automatically calculates device cost per day, week, month or year.

(Photo from p3international.com)

P3's new version does automatic calculation, and it also has a battery-powered memory to retain measurements even when unplugged. We still recommend using a short extension cord, because it's often difficult to read the Kill-A-Watt when it's plugged in to the wall. We recommend checking devices you suspect of high usage, and also those you don't. A laser printer, for example, uses very little power when idle, but things like an electronic pet-containment fence or even a doorbell can use much more than you'd suspect. Visit p3international.com/products/p4460.html for more information.

Nuvola: the Linux Choice for Cloud-y Music

Shawn Powers

Issue #216, April 2012

Nuvola Player (formerly known as google-music-frame) is a Linux application that integrates cloud-based music services into your Linux desktop. I've tested it only with Google Music, but Nuvola now supports Google Music, Grooveshark, Hype Machine and 8tracks. It also supports Last.FM scrobbling.

What makes Nuvola better than a standard Web browser is that it integrates with the Linux desktop. Nuvola gets its own tray icon and supports multimedia keys on keyboards that have them. I traditionally store my music files in Dropbox, but since Google Music has excellent support on Android phones, I find myself using the cloud-based service almost exclusively. Nuvola makes that experience much nicer. Check it out at https://launchpad.net/nuvola-player.

They Said It

All of the books in the world contain no more information than is broadcast as video in a single large American city in a single year. Not all bits have equal value.

—Carl Sagan

I am often amazed at how much more capability and enthusiasm for science there is among elementary school youngsters than among college students.

—Carl Sagan

If you wish to make an apple pie from scratch, you must first invent the universe.

—Carl Sagan

Somewhere, something incredible is waiting to be known.

—Carl Sagan

Absence of evidence is not evidence of absence.

—Carl Sagan

2-Plan Desktop—the Free Project Management App

Scott Anderson

Issue #216, April 2012

I have been searching for an eternity for a suitable project management software package that doesn't conflict with my limited budget. My needs seem like they should be relatively easy to fulfill: something simple, flexible, stable and robust that has the ability to grow with my needs, even though I may not be aware of what those needs actually are yet. My options have been extremely limited, as most of my peers have grown accustomed to the mainstream software (Microsoft Project) and the standard output it has produced for them. But, my situation has, without a doubt, changed for the better!

I recently found the answer to my endless on-line searches—2-Plan Desktop. 2-Plan is available as an open-source solution that runs on multiple operating systems, including my bread-and-butter Linux. It also comes with a feature set that is very comparable to Microsoft Project, but without the hefty price tag. Other features further distinguish 2-Plan from many of the other well-known solutions.

One of these features is the simple but effective graphical work breakdown structure (WBS). Users have the ability to create and reuse similar work packages across multiple projects with ease, saving time by eliminating duplication of work. By utilizing the drag-and-drop abilities within the WBS, users can define work packages with little-to-no requirements quickly and create a generalized top-down overview during the initiation phase. Then at a later time, users can revisit these work packages and further define as the requirements become available.

A second great feature is the ability to define various duration types for work packages. This feature is not common among all applications with the exception of Microsoft Project. Whether it be a fixed duration, manual or effort-driven, I can specify the duration type and work toward achieving an overall better-executed project plan.

Another great feature (or downloadable plugin that is available from the 2-Plan site) is the Extended Project Explorer. This feature is similar to mind-mapping software applications where the software displays your work packages in an animated graphical snapshot. Microsoft Project and Gantt Chart don't even offer this solution.

Despite the fact that 2-Plan is open source, it definitely does not come with a limited set of features or options that are available only in the so-called “premium packages”, as often is the case. There is no set limit to the amount of projects users are allowed to create within the software. An adequate forum is also available from the software creators to assist with any problems or suggestions for improvements you may have. The reporting features are more than adequate and similar to most other project management software packages.

Project managers tend to become very familiar with the ability to assign project milestones directly to work packages. Project milestones typically play an integral part within a project plan. 2-Plan is similar to MS Project as this feature is built in.

Template creation is a snap within 2-Plan. These templates include the basics, such as work packages, teams and roles that will cut down overall project planning time tremendously.

2-Plan incorporates the best of both the standard project management and Agile philosophies. I have found other software packages to lean more toward one side of the spectrum or the other, not allowing the flexibility or straightforwardness that is needed in real-world projects. I truly believe the software I use should allow me to work in a way that fits my standards best instead of making me alter everything I do to fit the software I'm using.

2-Plan allows me to do exactly that and work more efficiently in a manner to which I have now grown accustomed. Having tried many products during the years that claim to be similar to MS Project or Gantt Chart in their overall feature sets, most seem to fall short in their promises. Very few have delivered something close, and still fewer have delivered a software package with similar features and a price tag I could afford. 2-Plan Desktop has the features I need, and I have to say only one word when it comes to the pricing of the package—free. If you find yourself looking to stay on a more flexible OS and also needing a project management solution that can grow with you and your responsibilities, consider 2-Plan Desktop. It will fit into your budget—big or small. You will not be disappointed.

Announcing Our Latest eBook: Cool Projects

Katherine Druckman

Issue #216, April 2012

We're big fans of e-reader formats here at Linux Journal, and we know a lot of our readers are too, so we're expanding our offerings. We've just introduced a new special-edition compilation of some of the coolest projects, code snippets and how-tos to add to your electronic library. This brand-new special-edition eBook is full of how-tos and projects that will get you coding, hacking and making the most of your tech gear with a collection of articles from many of our most popular authors that is sure to spice up your eBook collection.

The Cool Projects eBook includes topics like programing an Arduino, router hacking, HTML5, Blender game development and shell scripting, and it should provide inspiration for readers to start working on something cool of their own.

Visit www.linuxjournal.com/cp-ebook to get yours!

LJ Archive