Follow the Australian Telecommunications scene NEWSLETTER- FREE TRIAL
The Linux distillery
Bringing the world of Linux to you, David cuts through the tech and shows you how it works and how to use it, in terms that apply to any distro. RSS
Technology news and Jobs arrow The Linux distillery arrow Developing for Linux netbooks
Developing for Linux netbooks E-mail
by David M Williams   
Monday, 07 July 2008
Disk space, too, is at a premium. The netbooks mentioned in this column all use small capacity solid state hard drives. This is a good and a bad thing. Benefits include fast boot time and low heat emission (and therefore less cooling required and so overall a quieter system.) Unfortunately the biggest disadvantage is solid state drives are more expensive than platter-based hard drives for much less available storage. Instead of a laptop with 120Gb of disk space, the typical netbook is looking at sizes in the range of 4Gb, plus or minus a handful of gigabytes.

The built-in command df is masterful for this purpose; it will enumerate all the file systems on your computer and report back their names, how much space has been used, how much space is available and where they are mounted.

By default, df lists disk sizes in terms of 1K blocks. You can get more meaningful output by appending the –h flag like so:

[david@dmw ~]$ df –h

This yields a more “human friendly” output, where size is represented in terms of megabytes (“M”) and gigabytes (“G”.) It is a simple matter for a program to execute this command and parse its output at run-time. Your application can make decisions based on this information, like whether to make local caches of data or not. If disk space is tight your app can intelligently disable caching.

Of course, another possibility is your application might opt to store its data somewhere other than the local disk. It could save information online, for instance. This leads us nicely into one more major consideration when programming for a netbook: are you online?

After all, netbooks are often designed with ubiquitous network connectivity in mind. Thus, your app may want to know if the device is presently networked. Once again a simple Linux command line comes in handy, and again it is a simple matter for a program to execute this at run-time and interrogate the output.

Use the command ifconfig by itself, without parameters, to list the current state of all the network interfaces on the computer. There will be several lines of output but the important things are to check for the word ‘UP’. If you like, you can also parse the file to determine precisely which network interface is up – this will help identify, for instance, if the computer is tethered in some way (eth0, the Ethernet port, is up) or if it is connected via WiFi or 3G modem or any other way.

So, let’s recap. Fundamentally, programming for the range of netbooks requires some consideration of the hardware constraints: display, RAM and disk size – not to mention an interest in whether the device is networked. These items can all be checked at the time the program is running which allows you to make decisions affecting how the program will render its display or how it will manage memory and data. All of this leads to a better user experience.

Of course, it also goes without saying but be sure to write your programs well: if you allocate memory, be sure to free it somewhere else. If you open a file, be sure to close it later. Memory leaks and bad coding are never a good thing but moreso when the device only has limited memory to begin with!

Powered By Joomla Tags

Please enable JavaScript in your browser to post your comment!



 
< Next story in category   Previous story in the category >
iTWire user statistics Visitors last 30 days
694,279
Subscribers 15,210
#1 independent technology news advertise here
  •   *  
  • Search
  • AdvSeach
  • Login
  • Events
  • FreeStuff

- Advertisement -

Featured Whitepapers

Follow iTWire on Twitter

About iTWire

iTWire is all about technology news, information, jobs and community for the IT and telecommunications industry professional. Subscribe to our free ICT daily newsletter