System Programming MCQs

System Programming MCQs

Our team has conducted extensive research to compile a set of System Programming MCQs. We encourage you to test your System Programming knowledge by answering these multiple-choice questions provided below.
Simply scroll down to begin!

1: Where would you expect to encounter the following code? for (i=1; i<argc; i++) { if (argv[i][0] == '-') {

A.   In the scanning for an internals function

B.   Anywhere at all

C.   In the iteration of the fscanf() function

D.   In the beginning of the main() function

2: What does the following line do? memset((char *)&ctl_addr, 0, sizeof(ctl_addr));

A.   Initializes a subset of memory pointed to by &ctl_addr

B.   Given that 0 is passed, it unsets the memory of ctl_addr

C.   Initializes the region of memory pointed to by &ctl_addr

D.   Allocates and initializes memory for variable ctl_addr

3: Which one of the following is NOT applicable in real-time Systems Programming?

A.   Timing Diagram

B.   Sequence Diagram

C.   Event Trace

D.   E-R Schema

4: When communicating across sockets, which of the following functions must be used when the socket is in a connected state?

A.   send()

B.   sendto()

C.   sendmsg()

5: Using a terminal you want to log in to an account on a remote computer and securely build. Which would you use?

A.   SSH

B.   RSH

C.   EncryptoTelnet

D.   rlogin

6: You see the line: listen (s, 3); You are looking at code for:

A.   A client's server

B.   A client's socket

C.   A server's clients

D.   A server's socket

7: Race conditions are caused by which of the following conditions in a multithreaded system?

A.   Proper program function requires all threads to run quickly

B.   Proper program function requires that all threads run at the same speed

C.   Proper program function is dependent on the execution sequence and timing of each thread

8: Some programme that streams data to a hard-disk file in a loop crashed before it closed the FILE pointer. When the output file is inspected side-by-side with the logs, it is clear that the fprintf() function previous to the crash was unsuccessful. Such a situation can be averted using which one of the following?

A.   fflush()

B.   fscanf()

C.   fbuffer()

D.   sscanf()

9: You want to listen on a port for some user-defined data stream. Would you use port 80?

A.   No, it is a 'well-defined' or reserved port.

B.   Yes, it is as good as any other port number.

C.   Yes, it is best ot use low numbers for port numbers.

D.   No, it is best to use three or four digit port numbers.

10: Using strncpy() to copy strings can help prevent which of the following attacks?

A.   Man-in-the-middle

B.   Buffer overflow

C.   Password cracking

D.   Denial of service

11: An orphan process occurs as a result of which of the following conditions?

A.   Child process terminates before its parent process

B.   Parent process terminates before its child process

C.   Parent and child process terminate simultaneously

12: The language of choice for Systems Programming is:

A.   PHP



D.   None of these

13: You want the same codebase to conditionally compile on and for different target platforms. Which of the following would you use?

A.   #itdef, #ifndef, and #endif

B.   Bit flags and bitwise OR'ing

C.   Use host-specific linkers

D.   if, else if, and else blocks

A.   Threads and processes exist separately

B.   Each thread exists within a process

C.   Each process exists within a thread

15: If a function is a 'blocking function' then:

A.   The function is written using block structuring

B.   The function must terminate before control returns to caller

C.   This function's purpose is to block unstructured calls

D.   This function has the highest possible priority

A.   Hard links can cross filesystems

B.   Files are deleted from disk when a hard link is removed

C.   Hard links are directory entries that point to the same inode as another file

17: Given the following line: my_fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_APPEND, 0644); Which statement is true?

A.   Syntax error; the second argument should be a single integer type

B.   Syntax error; the function takes only one more argument after 'filename'

C.   Runtime error opening the file as the various flags and modes are in conflict

D.   Opens a file descriptor, bitwise OR'ing output flags and in mode 644

18: The purpose of the poll() and select() system calls is to perform which of the following functions?

A.   Frequently check email and other network services

B.   Sample system process information for use by the top command

C.   Watch a set of file descriptors to see which are ready

19: If you see: int ff; write(ff, data, sizeof(data)); you know that ff is:

A.   a file descriptor

B.   a file struct

C.   a file function

D.   a file pointer

20: Is it good programming that the following function call is recursive? void func(unsigned long a) { unsigned long x; struct t_struct[] *p; : p = (struct t_struct *)alloca(a*sizeof(t_struct)); : While (x = f2()) func(x); : return; }

A.   Yes, because recursion is always preferable to iteration

B.   No, because iteration is always preferable to recursion

C.   No, because both stack depth and stack-frame size are unpredictable

D.   No, because there is more than one 'long integer' type

21: What is thread safety?

A.   Multiple threads can be executed without corrupting shared data

B.   Threads don’t start until all of the resources they require are available

C.   Threads can only access the data in its process

22: Which of the following fields in the stat struct contain last time the file was modified?

A.   st_ctime

B.   st_mtime

C.   st_atime

23: The sticky bit is used to enable which of the following features?

A.   Aggressive caching of a process

B.   Prevent users from renaming or deleting files created by other users

C.   Keep a process from swapping out of memory

24: Which of the following is correct for the standard file descriptors that are automatically opened in UNIX?





25: When a new process is created using fork(), which of the following describes the state of open file descriptors?

A.   The child inherits the parent’s

B.   The child always has an empty set of closed descriptors

C.   The child has distinct copies of the parent’s

D.   The child overwrites the parent’s

26: Which of the following provides the most random seed source for a pseudo random number generator?

A.   C rand() function

B.   /dev/random

27: Which of the following methods is used by system programs to access a character device (such as keyboards, audio cards, etc) on a UNIX system?

A.   Standard file access functions

B.   Pipes

C.   It depends on the device

28: Any code that calls a function whose interface includes the line raises(aLibrary:BookIsMissing); should do which one?

A.   #include errno.h header file

B.   Properly pass parameter for Book

C.   Pass both parameters by reference

D.   Implement an exception handler

29: Which of the following IPC mechanisms has an inode?

A.   semaphore

B.   named pipe

C.   shared memory

D.   unnamed pipe

30: Correct the following code: 10 int my_sock; : 20 my_sock = socket(anaddr.sin_family, SOCK_STREAM, 0); 21 if (my_sock >= 0) { /* error processing */ : }

A.   line 21: if (my_sock < 0) {

B.   line 20: my_sock = (int *)socket(anaddr.sin_family, SOCK_STREAM, 0);

C.   line 20: my_sock = socket(SOCK_STREAM, anaddr.sin_family, 0);

D.   line 10: SOCKET * my_sock;

31: Thrashing caused by loading a large file can be reduced by mapping the file to memory due to which of the following features?

A.   Mapped memory is cached

B.   Mapped memory uses prefetching

C.   Mapped memory uses lazy loading

A.   Removes the file from its directory

B.   Sets the file’s inode count to one (1)

C.   Moves the file in from one directory to another

33: The ioctl() function is used to interact with which of the following?

A.   Disk Drives

B.   Special character devices

C.   Virtual TTY lines

34: Using two resident processes on a PC and a Unix box, you are streaming unbuffered the contents of a text-file byte by byte from the PC to the Unix box where it is written byte by byte to the local hard disk. Eyeing the written file it is obvious that it is not quite right. You have likely run into which problem?

A.   Big endian versus littlen endian

B.   Text file versus binary file

C.   Ignoring the parity bit

D.   Not using buffered streaming

35: Given: int s, l; struct sockaddr_un sock_struct; Choose the option that corrects the following line: bind(s, sock_struct, l);

A.   bind(s, &sock_struct, l);

B.   bind(s, l, sock_struct);

C.   bind(s, sizeof(sock_struct), l);

D.   bind(sock_struct, s, l);

36: Which of the following could the fork() command return to the child process?

A.   0

B.   -1

C.   2054

D.   19456

37: In UNIX, a program requires higher privileges in order to do which of the following?

A.   Listen on a port below 1024

B.   Create a file in the /tmp directory

C.   Open a file in the owner’s directory

D.   exec() a new process

38: What does the following function return? Class retVal = [self class]; if ([retVal class] != [NSObject class]) { while ([retVal superclass] != [NSObject class]) retVal = [retVal superclass]; } return retVal;

A.   The present object's ultimate superclass or base class below the root object

B.   The present object's superclass or base class

C.   The present object's class

D.   The root object

39: Thread joining synchronizes threads by doing which of the following?

A.   The thread that calls join blocks until all of the joinable threads complete

B.   The system manages the shared resources for the joined threads

C.   The joined threads are added to a queue and executed serially

40: Which of the following can be called to remove zombie processes?

A.   wait4()

B.   free()

C.   close()

D.   flush()

41: When there are more fork() calls than wait() calls, which of the following is created?

A.   thread

B.   daemon

C.   orphan

D.   zombie

42: The following code is written to be accessed by multiple detached threads. : const char * c; char * d; : /* no lock and no mutex is used in any way here */ my_print_func (c, &d); : Which one of the following will happen when this code is re-entered by multiple threads?

A.   The code will sometimes run and sometimes cause a crash

B.   The code will always cause a crash

C.   It isn't possible to tell without looking at my_print_func()

D.   One thread will run while others will crash or abort

43: Which of the following is an advantage of using pipes over shared memory for interprocess communication?

A.   Pipes can be shared by more processes

B.   Pipes connect processes on multiple machines

C.   No additional work required on multiple CPU systems without cache coherence

D.   Faster access time

44: You want a char * that will contain the timestamp as YYYYMMDD-hh:mm:ss . You would use:

A.   sprintf()

B.   strftime()

C.   localtime()

D.   get_datetime()

45: What does the line #define S_IRWXG 0000070 relate to?

A.   Defining bitwise flags

B.   User-defined typing

C.   Flags for file access

D.   Alpha-numeric interchange

46: What type of attack can be mitigated by using ulimit, setrlimit(), and quotactrl()?

A.   Man-in-the-middle

B.   Password cracking

C.   Denial of service

D.   Buffer Overflow

47: In Multi-Threaded programming you want an active thread to push itself back in the background in favour of some other thread. You will use which function:

A.   sched_yield()

B.   pthread_detach()

C.   pthread_cancel()

D.   pthread_setschedparam()

48: What is a UNIX directory?

A.   A list of files

B.   A special type of inode

C.   A file that contains other files

49: In order to prevent signal handler race conditions, a developer must do which of the following?

A.   Call sigsetmask() to set the signal mask to be blocked

B.   Create a mutex within the handler to protect shared resources

C.   Call sigaction() to block the signal and set the signal mask at the same time

50: Which one is not a difference between exit() and _exit()?

A.   One is a true system call; the other is a library routine

B.   One does some work on its own, then calls the other

C.   One is for the main process; the other for forked processes

D.   One flushes and closes I/O streams; the other doesn't