Take Linux Programming Test

Test Outline

AutoConf/AutoMake, Makefiles
Cross Platform Installation
Program installation



C Programming
Data Structures
Files and Devices
Functions/Subroutines
Libraries
Memory Allocation
Terminals/User Interfaces

C++
Libraries
Object Oriented Programming



Debugging programs
Core files
GDB
Memory Leaks

Linux Programming Concepts
IPC
Pipes and Redirection
Processes
Semaphores, Shared memory, Message Queues
Sockets
Threads



Platform Independence
CPU/OS Architecture
Libraries

Revision Control
Checking items in/out of a CVS server
Resolving conflicts with CVS
Using CVS



RPC/CORBA
Concepts
Network Programming

X Programming
Communication
GTK+
Motif/LessTif
TCL/TK


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Which one of the following header files will allow you to use the 'pipe' function to create a pipe for IPC?
Choice 1
kernel.h
Choice 2
fifo.h
Choice 3
unistd.h
Choice 4
pipe.h
Choice 5
stdio.h
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


In a GTK+ based program, which one of the following portions is executed if no events are available?
Choice 1
gtk_sleep ()
Choice 2
gtk_wait ()
Choice 3
main ()
Choice 4
gtk_event_idle ()
Choice 5
gtk_main ()


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Question In which one of the following ways does CVS determine a conflict?
Choice 1
CVS calls GCC with -O9 which checks for conflicts in C code.
Choice 2
CVS connects to a central CVS server which provides conflict tracking information specific to the programming language in use.
Choice 3
CVS's understanding of conflicts is strictly textual.
Choice 4
CVS doesn't look for conflicts
Choice 5
It contains a database of programming language BNF. If the changes fundamentally change the way the program operates, it is flagged as a conflict.
Linux Programming (General), Question 3 of 40
Take a 15 minute break AFTER this question
© Copyright 2007 Brainbench All Rights Reserved.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Which one of the following libraries will halt a program that uses more memory than is requested in a malloc?
Choice 1
BugCatcher
Choice 2
xmalloc
Choice 3
malloc_debugger
Choice 4
chkmem
Choice 5
ElectricFence
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which one of the following functions is will allow you to prevent race conditions in threaded applications?
Choice 1
pthread_mutex_lock(), pthread_mutex_unlock()
Choice 2
pthread_join(), pthread_detach()
Choice 3
pthread_create()
Choice 4
pthread_attr_setschedpolicy()
Choice 5
pthread_attr_setschedparam()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which one of the following sets the gdb debugger set to print values in hex?
Choice 1
set output-hex 1
Choice 2
set output-radix 16
Choice 3
set output-radix 15
Choice 4
set output-mode 16
Choice 5
set output-mode hex

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You are writing a hex editing program that needs to run on several platforms.
Question Based on the above scenario, which one of the following is the platform independent way of clearing bit 2 from int n in C?
Choice 1
n &= 0xfffb;
Choice 2
n = 0x12;
Choice 3
n &= ~(1<<2);
Choice 4
n &= 0x04;
Choice 5
n == 0x02;
Linux Pro

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When "make" is run without any additional parameters, which one of the following targets is executed?
Choice 1
No targets get executed. "Make" requires a target.
Choice 2
The last target listed
Choice 3
The target labeled "all"
Choice 4
The target labeled "default"
Choice 5
The first target listed


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Display *display;

display = XOpenDisplay(NULL);
Question Based on the above scenario, which one of the following is returned by XOpenDisplay if the connection fails?
Choice 1
A struct
Choice 2
0
Choice 3
A pointer
Choice 4
-1
Choice 5
NULL

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You are selecting a user interface library for a client program that needs to compile and run in Linux, as well as in MS-Windows.
Question Based on the above scenario, which one of the following libraries will allow you to display a graphical user interface in both Linux and MS-Windows environments?
Choice 1
KDE libraries
Choice 2
Stdlib libraries
Choice 3
wxWindows libraries
Choice 4
WinLib libraries
Choice 5
GNOME libraries


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which one of the following functions is used to print output in a kernel module?
Choice 1
printk
Choice 2
kprint
Choice 3
printf
Choice 4
printd
Choice 5
prints

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What is main reason for splitting Linux interrupt handlers into a top half and a bottom half?
Choice 1
There is no reason to split Linux interrupt handlers.
Choice 2
To allow the handler to schedule time consuming operations to occur at a later time when interrupts have been enabled.
Choice 3
To separate the handler into a relatively small segment of code that stays resident and a larger optional segment which can be swapped in and out of main memory as needed.
Choice 4
To separate the user-space and kernel-space portions of the interrupt handler; thereby reducing the potential damage poorly written code can have on the rest of the system.
Choice 5
To encourage code reuse by providing a layer of abstraction between the interface to a handler and its functional parts.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which one of the following header files should be included in order for a C program to use Lesstif functions?
Choice 1
lesstif.h
Choice 2
xlib.h
Choice 3
motif.h
Choice 4
lt.h
Choice 5
Xm/Xm.h

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Code
test1: main.o foo.o bar.o
gcc -o myapp main.o foo.o bar.o

main.o: main.c a.h
gcc -c main.c

foo.o: foo.c a.h b.h
gcc -c 2.c

bar.o: bar.c b.h c.h
gcc -c bar.c

$ make
Makefile:2: *** missing separator. Stop.
Question The above code isn't working properly, which one of the following is a likely cause?
Choice 1
Not specifying the proper dependencies
Choice 2
Specifying improper parameters for gcc
Choice 3
Make can't find gcc
Choice 4
Using the colon to separate the target from the dependencies
Choice 5
Using spaces for the indented lines

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

How is a doubly linked list different from a singly linked list?
Choice 1
A doubly linked list can be used for process queuing in a round robin scheme; a singly linked list can only be used to create B-trees.
Choice 2
A doubly linked list is made using a struct; a singly linked list is made using an array.
Choice 3
A doubly linked list can be thought of as a virtual doughnut structure; a singly linked list is a virtual circle structure.
Choice 4
A doubly linked list holds a list of double precision reals; a singly linked list holds standard precision reals.
Choice 5
A doubly linked list has pointers to go forward and backward; a singly linked list can only go forward.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Which one of the following is the fastest form of IPC?
Choice 1
Named Pipes
Choice 2
Process Pipes
Choice 3
Shared Memory
Choice 4
Message Queue
Choice 5
Semaphores


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In which one of the following ways is a CVS conflict handled?
Choice 1
A warning is issued; the working copy is updated with the repository copy with markings detailing the overlap. Anyone can correct the overlap.
Choice 2
CVS doesn't monitor for conflicts.
Choice 3
CVS avoids conflicts by locking a section of code during the checkout process. The programmer works on that specific portion of code and commits it to the repository when complete. At that time, other programmers can check out that section of code.
Choice 4
A warning is issued; the latest code is merged with the working copy with overlaps marked. The programmer is expected to resolve the conflict and re-commit.
Choice 5
CVS automatically resolves conflicts using a transaction tracking system to monitor all changes.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Which one of the following is the most common form of semaphore?
Choice 1
Decimal semaphore
Choice 2
Hex semaphore
Choice 3
Unary semaphore
Choice 4
Multitasking semaphore
Choice 5
Binary semaphore
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which two assembly sources are usually included with the Linux kernel to handle differences between platforms?
Choice 1
bbootsect.s and vmlinux.lds.S
Choice 2
head.S and entry.S
Choice 3
reg_u_sub.S and div_Xsig.S
Choice 4
kernel.asm and io.asm
Choice 5
mm.asm and memalloc.asm

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which one of the following indicates the format of the curses WINDOW function?
Choice 1
WINDOW newwin(int num_of_lines, int num_of_cols, int start_y, int start_x);
Choice 2
WINDOW &newwin(int num_of_lines, int num_of_cols, int start_y, int start_x);
Choice 3
WINDOW *newwin(struct *screendef)
Choice 4
WINDOW *newwin(long int num_of_lines, long int num_of_cols, int start_y, int start_x);
Choice 5
WINDOW *newwin(int num_of_lines, int num_of_cols, int start_y, int start_x);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When a variable is created in C, which one of the following is its initial value?
Choice 1
It must be defined upon creation.
Choice 2
\0
Choice 3
Random
Choice 4
Null
Choice 5
Empty

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What needs to be done to debug a program using strace?
Choice 1
Compile the program with optimization level 3 using -O3
Choice 2
Compile the program with the strace header file included
Choice 3
Compile with '-gstrace'
Choice 4
Compile the program with '--strace'
Choice 5
Nothing, any program can be watched with strace.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The TCP/IP protocol is big-endian and the Intel x86 processor is little-endian.
Question Based on the above scenario, which one of the following should be done to bytes sent to the TCP/IP stack?
Choice 1
Nothing. The kernel takes care of issues related to the architecture.
Choice 2
Include netintet/in.h and use htonl, htons, ntohl, and ntohs to perform the conversion.
Choice 3
Include endian.h and use swapendian, pushendian, popendian, and memcp to perform the conversion.
Choice 4
Include convert.h to perform the needed conversions.
Choice 5
Include net/ethernet.h and use ethertype_ip, ethertype_tcp, and ether_hdr_len to read from or write to the ethernet device.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which one of the following command line switches is useful in creating makefile dependency lines?
Choice 1
autoconf's -dep switch
Choice 2
find's -dep switch
Choice 3
make's -j5 switch
Choice 4
diff's -newdep switch
Choice 5
gcc's -MM switch

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Which one of the following describes how a semaphore can be used?
Choice 1
To allow recursive access to a critical section.
Choice 2
To share memory with multiple processes.
Choice 3
To allow cooperative shared access to a critical section by providing shared update facilities.
Choice 4
To allow shared access to a critical section by multiplexing and backtracking.
Choice 5
To allow exclusive access to a critical section, one process at a time.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

With regard to curses, which one of the following does refresh(); do?
Choice 1
It resets the data structure that represents the screen.
Choice 2
It displays the data structure representing the screen to stdscr.
Choice 3
It clears the screen.
Choice 4
It re-draws the screen to get rid of errant characters from a dialup connection.
Choice 5
It clears the keyboard buffer.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which one of the following programs allows rapid development of GTK user interface statements for C and C++ programs?
Choice 1
gdv
Choice 2
Gimp
Choice 3
Glade
Choice 4
guile
Choice 5
TCL/TK

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which one of the following library calls is used to allocate memory in C and initialize it to zero?
Choice 1
alloca()
Choice 2
calloc()
Choice 3
realloc()
Choice 4
malloc()
Choice 5
bzero()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In which one of the following ways are lock files handled in Linux?
Choice 1
They are mandatory in nature. The kernel provides exclusive access to a process.
Choice 2
They are advisory in nature, but the kernel provides multiplex access via time offsets
Choice 3
They are advisory in nature. Your program handles them.
Choice 4
Lock files can be used for serial devices only.
Choice 5
They are mandatory in nature, but are handled in user space.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You need to design a distributed application that works with big-endian and little-endian systems.
Question In which one of the following ways does CORBA help to complete the above scenario?
Choice 1
By using IPC structures to relay data
Choice 2
By using middle-endian data
Choice 3
By marshaling and unmarshalling parameters and return values
Choice 4
By using a sockets based transport to move raw data between different networks
Choice 5
By moving data processing to a subprocess, creating an abstraction of the data that is unaffected by host byte order

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

main(argc, argv)
int argc;
char *argv[];
{/* main prog here */
}
Question Based on the above code, which one of the following describes *argv[0]?
Choice 1
A count of the number of command line arguments
Choice 2
A pointer to a null terminated string holding the name of the program
Choice 3
The name of the program
Choice 4
The first command line item the user passed, given after the program name
Choice 5
A stack pointer

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#define SCSI_IOCTL_SEND_COMMAND 1

struct sdata {
int inlen;
int outlen;
char cmd[256];
} scsi_cmd;

void unlockdoor( int fd )
{
scsi_cmd.inlen = 0;
scsi_cmd.outlen = 0;
scsi_cmd.cmd[0] = 0x1e;
scsi_cmd.cmd[1] = 0;
scsi_cmd.cmd[2] = 0;
scsi_cmd.cmd[3] = 0;
scsi_cmd.cmd[4] = 0;
scsi_cmd.cmd[5] = 0;

if (ioctl(fd,SCSI_IOCTL_SEND_COMMAND,(void *)&scsi_cmd))
perror("eject: door unlock ioctl error");
}
Question The above code is from the eject command. Which one of the following values is returned by ioctl if the error message is NOT printed?
Choice 1
0
Choice 2
256
Choice 3
1
Choice 4
-1
Choice 5
0x1e

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
r = c ? 2 : 3;
Question In the code listed above, to which one of the following values would be assigned to r if c==0 in C?
Choice 1
undefined
Choice 2
null
Choice 3
0
Choice 4
2
Choice 5
3


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When using Internet sockets, which one of the following levels of service does "streams" provide?
Choice 1
Connectionless, reliable, two way byte stream
Choice 2
Connectionless, non-reliable, one way byte stream
Choice 3
Local, inter process, reliable byte stream
Choice 4
Sequenced, reliable, two way byte stream
Choice 5
ASCII byte stream
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Which one of the following authentication methods is often used to check items in and out of an open-source project when using CVS?
Choice 1
pserver
Choice 2
xserver
Choice 3
serverd
Choice 4
cvsserver
Choice 5
rcsserver


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


You want to assure platform independent code between Linux and MS-Windows.
Question In which one of the following ways should a file be opened in order to ensure the above scenario?
Choice 1
Add a 'b' to the mode string.
Choice 2
Add a ;c' to the mode string.
Choice 3
Add a 'p' to the mode string.
Choice 4
Add a 'w' to the mode string.
Choice 5
Add a 'z' to the mode string.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

int n;
Question Based on the above code, which one of the following statements is TRUE about an integer variable in C?
Choice 1
A value of 0 is false; all others are true.
Choice 2
A value of -1 is false; all others are true.
Choice 3
A value of 1 is true; all other values are false.
Choice 4
A value of 0 is true; all other values are false.
Choice 5
Integer values are neither true nor false.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const MAXAVGSIZE = 200;

struct input_data {
double input_data<200>;
};

typedef struct input_data input_data;

program AVERAGEPROG {
version AVERAGEVERS {
double AVERAGE(input_data) = 1;
} = 1;
} = 22855;
Question Which one of the following methods should be used to process the above code?
Choice 1
gcc -O4
Choice 2
make
Choice 3
g++
Choice 4
gcc -C
Choice 5
rpcgen


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To which one of the following values do external variables initialize in C?
Choice 1
0
Choice 2
UNDEF
Choice 3
-1
Choice 4
Random
Choice 5
1

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In which one of the following ways is geometry management important in Motif/Lesstif?
Choice 1
To allow physical device characteristics to be determined prior to the layout stage
Choice 2
To allow mouse based window control
Choice 3
To allow fonts and windows to be scaled while maintaining a reasonable layout.
Choice 4
To allow coordinates to be input into a drawing program
Choice 5
To allow exact placement of widgets regardless of the display device


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

No comments: