After a few weeks of ignoring the issue I decided to try and get desktop effects working. When I would try to use desktop effects my screen would go blank (solid white). In fact I could not adjust my screen resolution either – it was stuck on 1280×1024 at 61Hz refresh (61?).

I knew I had the integrated Intel 915 graphics which isn’t exactly high-end but it should be enough for basic OpenGL support. I started searching and discovered a few things …

  1. glxinfo would fail on my machine. When I would run it the following would be displayed:
    • X Error of failed request: BadAlloc (insufficient resources for operation)
  2. System -> Hardware Information did detect that the Intel 915/910 graphics controller
  3. dmesg also detected the card

So I started hitting Google and discovered a utility called 915resolution on the Absolute Beginner’s Guide – http://absolutebeginner.wordpress.com/2006/08/20/absolute-beginner-guide-915resolution/. Following those directions I was able to get into a different resolution.

Still desktop effects would not work though. I needed to tackle the glxinfo problem.

After some more Google time I came across this page on ArchWiki: http://wiki.archlinux.org/index.php/Intel_915_Chipset. This page explained how to edit /etc/X11/xorg.conf to support the 915/910 driver (the key is the i810 driver).

While I was in there I noticed that the monitor settings were odd. The monitor ID was a string of gibberish and the refresh rates were all off. I have an HP M70 monitor (which is odd because I’ve never owned and HP computer and I can’t, for the life of me, remember how I came to own this) so I once again went to Google and discovered this page: http://ubuntuforums.org/showthread.php?t=381593

Once I made the suggested adjustments and restarted X (ctrl+alt+backspace) I was able to enable desktop effects and enjoy the fun.

I’m going to try running Beryl now.

I was building gcc and ran into this error:

../.././libgcc/../libdecnumber/decContext.h:52:50: error: gstdint.h: No such file or directory

I was pretty sure I had followed the directions correctly. I had installed the pre-reqs described here. I had enlisted in the source as described here. Then I switched into the gcc directory and ran ./configure – everything looked good so I ran make.

This is where things went downhill. Build errors galore.

It turns out that while I did skim the Configuration instructions I missed the part about not building from the src directory but rather from a sibling directory (or rather – not from the source dir). So I created a sibling directory, re-ran configure and then make. This time it got much further – but it still ended up hitting compile errors (a missing target in a makefile).

Even doing a clean build and re-running configure again could not resurrect the build.

I ended up having to start over with an `rm -f -r *` and getting the source over.

This time I ran configure from the sibling directory right from the start and everything was much happier.

Who would have thought that when the gcc maintainers went through the trouble of documenting the proper way to run configure that they would really mean that you were supposed to do it that way. 🙂

I posted this because when I hit the original problem I found several sites where people were asking why they were hitting that error and did not find a site where the cause was explained. Hopefully this will get enough Google Juice to save someone else the trouble.

gprof displays profile data for an object file. To use gprof I first needed to add “-g -pg” to my g++ options – i.e.

$ g++ -g -pg main.cpp

Then I simply needed to run the output executable (./a.out) which produced a file named gmon.out in the current directory.

Executing gprof is now enough to get some basic profiling information – e.g.:


% cumulative self self total
time seconds seconds calls s/call s/call name
100.52 9.73 9.73 5 1.95 1.95 run()
0.00 9.73 0.00 1 0.00 0.00 init()

The app ran for almost 10 seconds, made 5 calls to run which ran, on average, about 2 seconds per call.

Pretty simple high-level profiling.

The sample app was nothing more than a busy-wait (I wanted to busy wait otherwise all of the samples ended up in the call to sleep).

It’s code is:


#include
#include
#include

void init() {
srand(time(0));
}

void run() {
int limit = rand();

for(int i = 0; i

Some interesting command line options include:

-i Prints out some basic summary info (record counts)
-p Print basic call graph info
-z Display unused functions
-p Print basic call graph info
-A Print annotated source code

I intend to look more into gcov in the next few days to see what it has to offer.

While I'm on the topic of programming tools - what's available in the way of static analysis (i.e. lint) tools?

“more” displays the named file(s) one screenful at a time. Simple enough and quite useful – but it’s got a few handy little features I was unaware of prior to getting to more in Linux in a Nutshell.

The straight-forward usage is something like:

$ more file.txt

The result of this will be the first screenful of file.txt with a prompt indicating what percentage of the file was being displayed.Up to today that was the extent of how I used more.

Usually when I’m using more I’m looking for something but I’m not necessarily sure what so grep isn’t what I want. But I’ve often got a pretty decent idea of what I want – perhaps a keyword.

more supports jumping right to the first instance of the pattern you care about. If more is already running you can enter:

/pattern

And more will skip forward to the next instance of the pattern string. This can also be done upon invoking more using the command line syntax:

$ more +/pattern file.txt

If the pattern is found more will present the first match on the displayed screenful. If the pattern is not found more will indicate as much.

Now that you are at the first pattern match perhaps it was not the one you wanted. You can skip to the next match by hitting ‘n’ at the prompt. This is a great way to skip forward in the file quickly. If can skip more than one by typing a number before hitting ‘n’. For example at the more prompt if you type “12n” it will take you to the twelfth instance of the repeated pattern match.

Finally you can work with multiple files in more. The commands for moving between the files are “:n” to move the next file and “:p” to move to the previous. To help keep track of where you are you can use “:f” to display the file name and currently displayed line number.

There’s more going on than I previously realized.

I’m sorry. I couldn’t help it.

The theme I was using previously was causing command output to be trimmed which made the demo output more difficult to read.  I’m experimenting with other themes to see if I can find one that works better – in the mean time the look of the site may change a few times.

Sorry.

In the last couple of posts I’ve looked at how I can get the information I used to get from Windows Task Manager – CPU, memory, process stats and also how I can get disk information. Basically the commands I need to get a snapshot of my general system health.

Today I’m looking at a command to tell me how much disk space I have available on any given partition. The command to do this (or one of the many, I’m sure) is “df”.

Run without any arguments it reports the amount of free disk space on all mount file systems.

$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda2             30961696   2751648  26637288  10% /
varrun                  501248       100    501148   1% /var/run
varlock                 501248         0    501248   0% /var/lock
procbususb              501248       136    501112   1% /proc/bus/usb
udev                    501248       136    501112   1% /dev
devshm                  501248         0    501248   0% /dev/shm
lrm                     501248     33788    467460   7% /lib/modules/2.6.20-15-generic/volatile
/dev/sda1            113276220  40018800  73257420  36% /media/sda1
/dev/sda5              9444976       168   9444808   1% /media/sda5
/dev/scd1               628846    628846         0 100% /media/cdrom1

The -m option returns the values in megabytes which is a little more readable

$ df -m
Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/sda2                30237      2688     26013  10% /
varrun                     490         1       490   1% /var/run
varlock                    490         0       490   0% /var/lock
procbususb                 490         1       490   1% /proc/bus/usb
udev                       490         1       490   1% /dev
devshm                     490         0       490   0% /dev/shm
lrm                        490        33       457   7% /lib/modules/2.6.20-15-generic/volatile
/dev/sda1               110622     39081     71541  36% /media/sda1
/dev/sda5                 9224         1      9224   1% /media/sda5
/dev/scd1                  615       615         0 100% /media/cdrom1

I can tack a “-T” on to that to get the file system type as well

$ df -Tm
Filesystem    Type   1M-blocks      Used Available Use% Mounted on
/dev/sda2     ext3       30237      2688     26013  10% /
varrun       tmpfs         490         1       490   1% /var/run
varlock      tmpfs         490         0       490   0% /var/lock
procbususb   usbfs         490         1       490   1% /proc/bus/usb
udev         tmpfs         490         1       490   1% /dev
devshm       tmpfs         490         0       490   0% /dev/shm
lrm          tmpfs         490        33       457   7% /lib/modules/2.6.20-15-generic/volatile
/dev/sda1     ntfs      110622     39081     71541  36% /media/sda1
/dev/sda5     vfat        9224         1      9224   1% /media/sda5
/dev/scd1  iso9660         615       615         0 100% /media/cdrom1

-h can be used to make the output even more “human” readable:

$ df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2     ext3     30G  2.7G   26G  10% /
varrun       tmpfs    490M  100K  490M   1% /var/run
varlock      tmpfs    490M     0  490M   0% /var/lock
procbususb   usbfs    490M  136K  490M   1% /proc/bus/usb
udev         tmpfs    490M  136K  490M   1% /dev
devshm       tmpfs    490M     0  490M   0% /dev/shm
lrm          tmpfs    490M   33M  457M   7% /lib/modules/2.6.20-15-generic/volatile
/dev/sda1     ntfs    109G   39G   70G  36% /media/sda1
/dev/sda5     vfat    9.1G  168K  9.1G   1% /media/sda5
/dev/scd1  iso9660    615M  615M     0 100% /media/cdrom1

“-t” and “-x” can be used to include or exclude file systems of a specific type (respectively). “-i” provides information on inodes. “-l” only returns local file systems (since all of mine are local this does not create an interesting demo).

There are a few other options but this tool provides the answer to the basic question “how much disk space is available?”

Top provides information about the processes currently running sorted by their CPU usage. Like Windows Task Manager it refreshes frequently and gives basic stats on CPU and memory usage. Another similarity is that it can be used to adjust process priority, sort by other criteria (pid, etc), etc.

A sample probably says it best:

Tasks: 103 total,   2 running, 100 sleeping,   0 stopped,   1 zombie 
Cpu(s):  8.5%us,  2.0%sy,  0.8%ni, 79.6%id,  8.8%wa,  0.1%hi,  0.2%si,  0.0%st 
Mem:   1002500k total,   442988k used,   559512k free,    60144k buffers 
Swap:  2096472k total,        0k used,  2096472k free,   236868k cached    

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND 
 5103 root      15   0 62556  21m 6476 S  4.0  2.2   0:15.16 Xorg 
    1 root      18   0  2912 1844  524 S  0.0  0.2   0:01.09 init 
    2 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0 
    3 root      34  19     0    0    0 S  0.0  0.0   0:00.00 ksoftirqd/0 
    4 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 watchdog/0 
    5 root      10  -5     0    0    0 S  0.0  0.0   0:00.01 events/0 
    6 root      16  -5     0    0    0 S  0.0  0.0   0:00.00 khelper 
    7 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kthread 
   30 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kblockd/0 
   31 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpid 
   32 root      20  -5     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify 
  139 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 kseriod 
  163 root      16   0     0    0    0 S  0.0  0.0   0:00.00 pdflush 
  164 root      15   0     0    0    0 S  0.0  0.0   0:00.00 pdflush 
  165 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 kswapd0 
  166 root      11  -5     0    0    0 S  0.0  0.0   0:00.00 aio/0 
 1991 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 ksuspend_usbd 
 1992 root      10  -5     0    0    0 S  0.0  0.0   0:00.00 khubd

It’s worth noting that to get that output I needed to run top in batch mode and redirect to a file – the command line option to do that is ‘-b’ (i.e. top -b > output.txt).

When running top in non-batched mode there are a ton of ways to filter. Some that I found helpful were:

z Toggle color/mono mode
F Select filter criteria (it brings up a screen of filter options)
h Display help
i Toggle suppression of idle processes
P Sort by CPU usage (this is the default)
T Sort by time or cumulative time.
m Toggle display of memory stats
W Write out current settings to the ~/.toprc file
k Prompted for pid to kill
r Apply renice to a process (renice can adjust the process priority)

This is just the tip of the iceberg. I had no idea how much was available with the top command.