Hardware Reference
In-Depth Information
the bitmap image of a penguin appears in the CPU #3 section on the display as
shown in Fig. 6.23 .
In the same way, when a penguin process is assigned to CPU #1, the penguin
appears in the CPU #1 section. Likewise, when a penguin process is assigned to
CPU #2, the penguin appears in the CPU #2 section. This application consists of
three sub-applications. They are initiated out of a shell script. First, the DU initial-
ization sub-application is initiated. It disables the DU, sets the pixel format to the
16-bit RGB 5:6:5 format, fills all of the pixels with the black color, and enables
the DU. Second, the background painting sub-application is initiated. It paints
the contents of the 640 × 480 bitmap file, in which the CPU #0, CPU #1, CPU #2,
and CPU #3 sections are drawn, onto “/dev/fb0,” which is plane 0 of the DU. Third,
several penguin drawing sub-applications are created and killed after a while. The
penguin drawing sub-application clears the penguin image at the previous position
whose initial position is given arbitrarily, obtains the CPU #ID number from the/
proc/xxxxxx/stat file where xxxxxx is the decimal process ID (PID) of that sub-
application process, calculates the position inside the corresponding CPU section
randomly using the rand() of <stdlib.h>, and draws the 82 × 102 pixel bitmap image
of a penguin at that position. This sub-application repeats the above procedures
continuously until an interrupt is signaled and clears the penguin image upon
receiving an interrupt. The Bourne shell script below creates and kills some pen-
guin sub-applications:
Line 0001: ./penguin 0/dev/fb0 &
Line 0002 : sleep 1
Line 0003: ./penguin 1/dev/fb0 &
Line 0004: sleep 1
Line 1001: kill -2 `ps a | grep 'penguin 0' | grep -v grep | awk '{print $1}'`
Line 1002: sleep 1
Line 1003: kill -2 `ps a | grep 'penguin 1' | grep -v grep | awk '{print $1}'`
Line 1004: sleep 1
Initially, no penguin images are on the display. The line 0001 above creates a
penguin drawing sub-application process whose image is named “0” and draws it
on/dev/fb0, the plane 0 of the DU. This process will be created on the same CPU
where the parent shell script process exists. The load balancer of a less busy CPU
might pull one or more processes from the busiest CPU. Line 0002 waits for 1 s.
Line 0003 creates a penguin drawing sub-application process whose image is named
“1” and draws it on/dev/fb0. The load balancer of a less busy CPU might pull one
or more processes from the busiest CPU. Line 0004 waits for 1 s. After creating
several penguin sub-application processes, they are killed in turn. Line 1001 kills
the penguin drawing sub-application process named “0.” The “kill -2 [PID]” command
Search WWH ::




Custom Search