UpFront

diff -u: What's New in Kernel Development

Zack Brown

Issue #195, July 2010

More and more progress continues to be made on eradicating the big kernel lock (BKL). We've now reached the stage where only relatively few parts of the kernel still depend on the BKL. Arnd Bergmann, who's been maintaining his own source tree specifically targeting the BKL, recently announced that his own work, and the contributions of lots of other folks, had removed the BKL from the entire core kernel, and it was now possible to build a kernel that had no instance of the BKL at all. There still are some high-profile drivers that rely on the BKL though (for example, USB and VFAT), as well as a lot of more obscure drivers. Arnd also acknowledges that some of his BKL-removal patches may be superseded by other people's efforts in a particular area. For example, he took the BKL out of the TTY layer, but Alan Cox has been planning to do work on the TTY layer himself that probably would go into the official tree instead of Arnd's work. But, the upshot of all this is that the kernel is likely to become much more friendly to threaded applications in the fairly near future.

With the modern proliferation of virtual systems like VMware, Xen and KVM, people want to write code that supports their particular virtualization implementation within the host system. The result can be some duplicated features, and potentially an approach that favors the person's own preferred virtualization system over the generic services the kernel is supposed to provide. That seems to have happened recently, when VMware submitted some more work on its balloon driver. A balloon driver allows memory allocation to fluctuate, so the virtual system can release memory back to the host system, and then claim more memory later, at need. It's a polite way to be a virtualization system.

In this case, however, Andrew Morton pointed out that an even more polite approach would be to extend the memory handling abilities the kernel already possesses. The code to handle system hibernation seemed to him like a natural starting point for that approach. The only drawback is that none of the virtual system developers had considered that possibility, so it would mean backtracking their plans. But, it seems like either that, or some similar extension of existing functionality, will be the new direction, at least for balloon drivers.

One of the most interesting aspects of kernel development is the balance struck between letting people contribute in the best way they can and keeping a rein on the messiness that can creep into a project when a lot of people are all pounding on it together. Recently, Linus Torvalds caught Phillip Lougher copying some ugliness from include/linux/mm.h into other include files needed for SquashFS. Phillip knew there was a problem with that ugliness, but he'd cleaned it up as much as he could, and any further effort would involve a major detour from his SquashFS work. And anyway, the mess already was in the code, so it didn't seem like such a high priority to him.

But, Linus adamantly refused to let the ugliness propagate further into the code. He wasn't blaming Phillip for it, but he asked Phillip to work on cleaning it up more, and asked H. Peter Anvin to get into it with him. The end result was a delay in accepting the SquashFS changes and a bit of a detour for Phillip, but the work was at least relevant to what Phillip wanted to do, and it was going to have a fairly large impact on the cleanliness of this part of the kernel.

Wi-Fi on the Command Line

Joey Bernard

Issue #195, July 2010

More people than ever are using wireless networks as their primary networking medium. Great programs are available under X11 that give users a graphical interface to their wireless cards. Both GNOME and KDE include network management utilities, and a desktop-environment-agnostic utility called wicd also offers great functionality. But, what if you aren't running X11 and want to manage your wireless card? I don't cover how to install and activate your card here (for that, take a look at projects like madwifi or ndiswrapper). I assume your card is installed and configured properly, and that it is called wlan0. Most of the utilities mentioned below need to talk directly to your wireless card (or at least the card driver), so they need to be run with root privileges (just remember to use sudo).

The first step is to see what wireless networks are available in your area. A utility called iwlist provides all sorts of information about your wireless environment. To scan your environment for available networks, do the following:

sudo iwlist wlan0 scan

You'll see output resembling:

Cell 01 - Address: 00:11:22:33:44:55
          ESSID:"network-essid"
          Mode:Master
          Channel:11
          Frequency:2.462 GHz (Channel 11)
          Quality=100/100  Signal level:-47dBm  Noise level=-100dBm
          Encryption key:off
          .
          .
          .

The details (address and essid) have been changed to protect the guilty. Also, the ... represents extra output that may or may not be available, depending on your hardware. You will get a separate cell entry for each access point within your wireless card's range. For each access point, you can find the hardware address, the essid and the channel on which it's operating. Also, you can learn in what mode the access point is operating (whether master or ad hoc). Usually, you will be most interested in the essid and what encryption is being used.

Once you know what's available in your immediate environment, configure your wireless card to use one of these access points using the iwconfig utility to set the parameters for your wireless card. First, set the essid, which identifies the network access point you want:

sudo iwconfig wlan0 essid network-essid

Depending on your card and its driver, you may have the option to set the essid to the special value “any”. In this case, your card will pick the first available access point. This is called promiscuous mode.

You also may need to set the mode to be used by your wireless card. This depends on your network topology. You may have a central access point to which all of the other devices connect, or you may have an ad hoc wireless network, where all of the devices communicate as peers. You may want to have your computer act as an access point. If so, you can set the mode to master using iwconfig. Or, you simply may want to sniff what's happening around you. You can do so by setting the mode to monitor and passively monitor all packets on the frequency to which your card is set. You can set the frequency, or channel, by running:

sudo iwconfig wlan0 freq 2.422G

Or by running:

sudo iwconfig wlan0 channel 3

You can set other parameters, but you should consider doing so only if you have a really good reason. One option is the sensitivity threshold, which defines how sensitive the card is to noise and signal strength, and you can set the behavior of the retry mechanism for the wireless card. You may need to play with this in very noisy environments. Set the maximum number of retries with:

sudo iwconfig wlan0 retry 16

Or, set the maximum lifetime to keep retrying to 300 milliseconds with:

sudo iwconfig wlan0 retry lifetime 300m

In a very noisy environment, you also may need to play with packet fragmentation. If entire packets can't make it from point to point without corruption, your wireless card may have to break down packets into smaller chunks to avoid this. You can tell the card what to use as a maximum fragment size with:

sudo iwconfig wlan0 frag 512

This value can be anything less than the size of a packet. Some cards may not apply these settings changes immediately. In that case, run this command to flush all pending changes to the card and apply them:

sudo iwconfig wlan0 commit

Two other useful commands are iwspy and iwpriv. If your card supports it, you can collect wireless statistics by using:

sudo iwspy wlan0

The second command gives you access to optional parameters for your particular card. iwconfig is used for the generic options available. If you run it without any parameters (sudo iwpriv wlan0), it lists all available options for the card. If no extra options exist, you will see output like this:

wlan0      no private ioctls

To set one of these private options, run:

sudo iwpriv wlan0 private-command [private parameters]

Now that your card is configured and connected to the wireless network, you need to configure your networking options to use it. If you are using DHCP on the network, you simply can run dhclient to query the DHCP server and get your IP address and other network settings. If you want to set these options manually, use the ifconfig command (see the man page for more information).

Non-Linux FOSS

Mitch Frazier

Issue #195, July 2010

Linux continues to make headway in embedded devices, but for many devices, it's just too heavy, and out of the box, it doesn't have real-time support.

NuttX is a Real Time Operating System (RTOS) for small- to moderate-size embedded systems. It strives to be standards-compliant (POSIX and ANSI) to the fullest extent possible for a deeply embedded environment. NuttX is fully preemptible and includes a filesystem, C library, networking and USB device support.

NuttX has been ported to numerous platforms/architectures ranging from small 8-bit systems, such as the 8052 and the M68HC12, to larger 32-bit systems, such as the ARM Cortex-M3. NuttX can be built with Linux and with Cygwin. Depending on the options that are enabled, NuttX can be squished down to around 20K or so. Around 50K gives you room for a full-featured build.

NuttX was first released in 2007 and is actively developed. It has had 49 releases since then and currently is at version 5.2. NuttX is hosted on SourceForge at nuttx.sourceforge.net and is licensed under a BSD license.

LJ Index, July 2010

1. Number of machines registered at The Linux Counter: 136,986

2. Percent of Linux Counter machines running 2.0 kernels: 0.3

3. Percent of Linux Counter machines running 2.2 kernels: 0.8

4. Percent of Linux Counter machines running 2.4 kernels: 6.5

5. Percent of Linux Counter machines running 2.6 kernels: 92.2

6. Average uptime for machines registered at The Linux Counter (in days): 70.3

7. Longest uptime of a machine registered at The Linux Counter (in days): 1,856.4

8. Number of Distro Watch-listed distros whose names end in the letters “ix”: 21

9. Number of Distro Watch-listed distros whose names contain the acronym “OS”: 14

10. Number of Distro Watch-listed distros whose names contain the acronym “BSD”: 9

11. Number of Distro Watch-listed distros whose names contain the letters “buntu”: 10

12. Number of Distro Watch-listed distros whose names contain accented characters: 3

13. Number of Distro Watch-listed distros whose names contain digits (0–9): 8

14. Number of Distro Watch-listed distros whose names contain exactly one digit (0–9): 3

15. Number of Distro Watch-listed distros whose names begin with a digit (0–9): 2

16. Number of Distro Watch-listed distros whose names begin with the letter “Q”: 1

17. Number of Distro Watch-listed distros whose names begin with the letter “S”: 30

18. Number of digits that don't appear in any Distro Watch-listed distro name: 5

19. Number of letters that don't appear as the first letter in any Distro Watch-listed distro name: 0

20. Ranking of stallman.org in a Google search from “RMS”: 4

1–7: counter.li.org

8–19: Distro Watch + grep, etc.

20: Google

Repo, Man

Shawn Powers

Issue #195, July 2010

Sure, it was a cheesy 1980s movie, but more important, I'd like to focus on the “Repo” part of it. As Linux users, software repositories are second nature to us. For new users, however, that's not the case.

Take my father for instance. (Hi Dad!) He recently started using Linux on his desktop machine, and once he was comfortable with the base install, he wanted to try some other applications. As a longtime Windows user, he called me to ask where a person goes to download software, specifically Amarok. The concept of preloaded software repositories was foreign to him, but I hope a rather exciting one once I explained it.

We often tout security, stability and freedom when we talk about why Linux is so great. It's funny that the little things we take for granted, things like “convenience”, already are built in to our favorite operating system. I rambled on-line about this as well, and because my space here is limited, feel free to add your two cents on our Web site: www.linuxjournal.com/content/linux-where-crapware-goes-die.

apt-get install a_great_day!

Tablets, the New Netbooks

Shawn Powers

Issue #195, July 2010

Tablet computers aren't new, just like tiny-form-factor computers weren't new. Much like with the Netbook craze, the new tablet computing craze has much to do with money and less to do with innovation. Don't get me wrong. I think we'll see tons of innovation, but it will be driven by consumers' pocketbooks (and their willingness to open them) as opposed to some amazing new concept in computer design.

I certainly thought Netbooks were the perfect place for Linux to gain a stronghold. Sadly, poor implementation by vendors and lack of a standard desktop caused Linux to be the ugly alternative to Windows—something that should make us all shudder. Maybe, just maybe, tablets will be our second chance.

Certainly, Apple's iPad has made a huge jump start into the hearts of spendy Americans. This time around, however, the Linux community has something we didn't have before: Android. Love it or hate it, Google has managed to provide a rather standard platform that is designed to work on mobile devices—and tablets!

So, to all my fellow Netbook owners who bought Netbooks just because they looked cool, let's buy tablets! I don't really care which one, but please, buy one that runs Linux.

They Said It

I think the biggest mistake most people make when they pick their first job is they don't worry enough about whether they'll love the work, and they worry more about whether it's a good experience.

—Steve Ballmer

Save early, save often.

—Alwin Lee and everyone else who uses Microsoft Word

From then on, when anything went wrong with a computer, we said it had bugs in it.

—Rear Admiral Grace Murray Hopper, US Navy

AOL is like the cockroaches left after the nuclear bomb hits. They know how to survive.

—Jan Horsfall, VP of marketing for Lycos

The Linux philosophy is “Laugh in the face of danger.” Oops. Wrong One. “Do it yourself.” Yes, that's it.

—Linus Torvalds

If Gore invented the Internet, I invented spell-check.

—Former Vice President J. Danforth Quayle

What is the difference between apathy and ignorance? I don't know and I don't care.

—World Entertainment War

My problem with Linux is, that it makes it very difficult to handle porn.

—Kshitij Sobti (Posted on thinkdigit.com on April Fools' Day 2010)

Dear Canonical, I Can Haz Ubuntu One Source?

Shawn Powers

Issue #195, July 2010

I love Dropbox (www.dropbox.com) and use it on all my computers, so I was excited to see Canonical do something similar with its Ubuntu One program. That excitement was quick to dwindle, however, when I realized that although the client software is completely open source, the server bits are not. Those of us running a huge network of computers can't set up our own Ubuntu One server internally, and we can't hope for the community to add support for other operating systems.

Ultimately, I wish Dropbox would become open source. That would not only give us cross-platform support, but also remove the “Ubuntu” slant that Canonical's product currently sports. My suspicion, however, is that sooner or later, Google will realize Dropbox is the Gdrive it has never had—and buy it. Although that would be really cool, and more people would adopt the already-amazing Dropbox, it also would mean no chance of Dropbox coming to a Linux server any time soon.

So again, Canonical, please open the source to Ubuntu One. You still can offer your cloud solution, but we also can make our own little clouds in-house. Who knows, maybe the community will add features and functionality that you'll want to adopt yourself. We'll be happy to share back!

LinuxJournal.com

Katherine Druckman

Issue #195, July 2010

This month, I'd like to take the time to acknowledge the many people involved with Drupal, the open-source Web project that powers LinuxJournal.com. Although most of the core project is the work of a small group of developers whose thousands of contributions are the driving force behind Drupal's evolution, there are thousands of people contributing code and modules to the community. These contributions are what allow me to produce LinuxJournal.com without a large Web team, and I am extremely grateful for them. Although I frequently cite Drupal's flexibility and power as the reason I am able to remain a one-person team, this is absurdly misleading. I am a one-person team with a support system of thousands, and I also can credit Addison Berry of Lullabot with getting me through many tough spots throughout the past year.

I believe Drupal is the best Web platform around, but I also believe that is a result of having the best Web community around. I am thrilled to be a small part of it.

With sites like WhiteHouse.gov adopting Drupal, this is an exciting time to be a Drupaler, and I encourage others to use it and get involved. Thank the community that makes your own work better, and don't forget to make your own contributions.