100% found this document useful (1 vote)
160 views

Page 1 of 18 UNIX Programming

This document contains questions and multiple choice answers about various UNIX programming concepts. Specifically, it covers topics like file manipulation functions like open, close, read, write, fcntl, lseek; file permissions and ownership functions like chmod, chown; directory functions like mkdir, rmdir, opendir; and standard I/O functions like fopen, fclose, fread, fwrite. The document is a practice test for a UNIX programming midterm exam with questions ranging from basic concepts to more advanced topics like file locking and process structures.

Uploaded by

araghav_23
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
160 views

Page 1 of 18 UNIX Programming

This document contains questions and multiple choice answers about various UNIX programming concepts. Specifically, it covers topics like file manipulation functions like open, close, read, write, fcntl, lseek; file permissions and ownership functions like chmod, chown; directory functions like mkdir, rmdir, opendir; and standard I/O functions like fopen, fclose, fread, fwrite. The document is a practice test for a UNIX programming midterm exam with questions ranging from basic concepts to more advanced topics like file locking and process structures.

Uploaded by

araghav_23
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

UNIX Programming Page 1 of 18

JNTU ONLINE EXAMINATIONS [Mid 2 - UNIX Programming]

1. In open function, oflag argument is O _ TRUNC


a. truncates file if exists
b. truncates file if doesnot exists
c. does not truncate if file exists
d. does not truncate if doesnot exists

2. In open function, oflag argument is O _ CREAT | O _ EXCL


a. truncates file exists
b. gives error if file does not exists
c. gives error if file exists
d. truncates if file doesnot exists

3. The header file to be included for read function is _ _ _ _ _ _ _ _ _ _ _ _ .


a. unistd.h
b. stdio.h
c. types.h
d. sys.h

4. The creat function returns


a. file descriptor open for write only if ok
b. -1 on error
c. 1 on error
d. File descriptor close for write only if ok

5. The open function returns


a. 1 on error
b. 0 on error
c. File descriptor if ok
d. 1 on success

6. The header file to be included for write function is _ _ _ _ _ _ _ _ _ _ .


a. unistd.h
b. stdio.h
c. types.h
d. sys.h

7. Write function returns a value


a. 1 if end of file
b. Number of bytes written on success
c. 0 on failure
d. 1 on failure

8. The header file to be included for close function is _ _ _ _ _ _ _ _ _ _ .


a. unistd.h
b. stdio.h
c. types.h
d. sys.h

9. Close function _ _ _ _ _ _ _ _ _ _
a. returns 1 on failure
b. holds all locks
c. retuns 1 on success
d. returns 0 on success

10. When a process exits, all open files will be _ _ _ _ _ _ _ _ _


a. opened till system is down
b. files will be automatically closed
c. files will not be closed
d. all files will be opened

11. _ _ _ _ _ _ _ _ _ _ _ _ system call is used to change the behavior of an open file.


a. fcntl
b. ioctl
c. fork
d. dup

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 2 of 18

12. The system call that is used to change the terminal characteristics like baud rate, parity, number
of bits per character, etc.. is
a. umask
b. ioctl
c. fork
d. dup

13. In fcntl function, if cmd = F _ GETLK


a. duplicate an existing descriptor
b. get file descriptor flags
c. set file status flags
d. get record locks

14. In fcntl function, if cmd = F _ GETFD


a. duplicate an existing descriptor
b. get file descriptor flags
c. set file status flags
d. get record locks

15. The fcntl function can change properties of a _ _ _ _ _ _ _ file


a. already open
b. already closed
c. does not exit
d. corrupt

16. Each process has a file mode creation mask. It is set with the _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
system call.
a. mask
b. umask
c. ioctl
d. dup

17. The function _ _ _ _ _ _ _ is used to get file status information.


a. dup
b. fcntl
c. lseek
d. stat

18. Before a read or write, an open file can be positioned using


a. dup
b. fcntl
c. lseek
d. stat

19. An existing file descriptor is duplicated by _ _ _ _ _ _ system call.


a. fork
b. stat
c. ioctl
d. dup

20. In UNIX system lets us read and write anywhere in the file known as random access, this
capability is made possible with _ _ _ _ _ _ _ system call.
a. dup
b. fcntl
c. lseek
d. stat

21. The function _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ writes the null terminated string to the specified stream.
a. fputs
b. fread
c. fwrite
d. fopen

22. Line at a time I/O input is provided by


a. getc
b. fgets
c. fgetc
d. fputs

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 3 of 18

23. By default, the stream that is opened is _ _ _ _ _ _ _ _ _ _ _ _ .


a. fully buffered
b. line buffered
c. unbuffered
d. partially buffered

24. The _ _ _ _ _ _ _ _ _ function allow us to read one character at a time.


a. getc
b. putc
c. fgets
d. fputc

25. The function getchar is equivalent to


a. Putchar( c )
b. Putc( c, stdout )
c. Getc ( stdin )
d. Getc( stdout)

26. _ _ _ _ _ _ _ _ _ _ _ _ _ _ function is used to open a specified file.


a. fclose
b. fflush
c. fseek
d. fopen

27. An open stream is closed by calling _ _ _ _ _ _ _ _ _ function.


a. fclose
b. fflush
c. fseek
d. fopen

28. _ _ _ _ _ _ _ _ _ _ _ function forces the writing of a buffer to a file or device.


a. fclose
b. fflush
c. fseek
d. fopen

29. The function to position a standard I/O stream is


a. fclose
b. fflush
c. fseek
d. fopen

30. In fflush function, if the stream argument is NULL, fflush flushes


a. all closed input streams
b. all opened input streams
c. all closed output streams
d. all opened output streams

31. Unlink file


a. removes file from file system
b. reduces link count for a file
c. reduce link count of a file, if it is zero the file be removed from file system
d. link the file

32. If a sticky bit is set for a directory, a file in the directory can be removed only if the user has _ _ _
_ _ _ _ _ _ _ _ _ _ permission for the directory.
a. read
b. write
c. execute
d. no

33. The _ _ _ _ _ _ _ system call links an existing file to a new file.


a. unlink
b. link
c. create
d. more

34. _ _ _ _ _ _ _ _ _ is an indirect pointer to a file.


a. symbolic link

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 4 of 18

b. hard link
c. user link
d. process link

35. The command to create softlink is


a. link
b. hwlink
c. symlink
d. swlink

36. The _ _ _ _ _ _ _ _ _ function that allows us to change the file access permissions for existing
file.
a. chown
b. chmod
c. chgrp
d. chusr

37. To change the file access permissions, the process must have
a. normal user permission
b. group permission
c. super user permission
d. other permission

38. The _ _ _ _ _ _ _ _ _ _ _ _ function allow us to change the user ID of a file.


a. chown
b. chmod
c. chgrp
d. chusr

39. The _ _ _ _ _ _ _ _ _ _ _ _ function allow us to change the group ID of a file.


a. chown
b. chmod
c. chgrp
d. chusr

40. Link to directory can be created by


a. any user can create
b. any group can create
c. any other group can create
d. only super user can create

41. mkdir dirname


a. creates a directory with . and .. files
b. creates an empty directory
c. create a file
d. creates a directory without any permission

42. mkdir creates a dot -dot file in the new directory, dot-dot specifies
a. current directory
b. child directory
c. it is not a file
d. parent directory

43. As soon as user logins to the system, the user enters in


a. home directory
b. root
c. current directory
d. $ prompt

44. The system call _ _ _ _ _ _ _ _ _ _ opens a directory for reading.


a. fopen
b. readdir
c. mkdir
d. opendir

45. The function to fill in the buffer with the current directory
a. mkdir
b. gets
c. getcwd

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 5 of 18

d. puts

46. dir creates a dot file in the new directory, dot specifies
a. current directory
b. child directory
c. it is not a file
d. parent directory

47. rm file
a. removes file from file system
b. reduces link count for a file
c. reduce link count of a file, if it is zero the file be removed from file system
d. link the file

48. We can change the current working directory of a calling process by calling the _ _ _ _ _ _ _ _ _ _
function.
a. chown
b. chdir
c. chmod
d. chgrp

49. The function to read the contents of a directory


a. fopen
b. readdir
c. mkdir
d. opendir

50. The system call to create a directory


a. mkdir
b. rmdir
c. chdir
d. getcwd

51. In the process structure, the _ _ _ _ _ _ _ _ _ _ _ _ _ _ data contains data elements that are not
initialized by the program but are set to zero before the process starts execution.
a. initialized read-write
b. initialized read-only
c. uninitialized
d. initialized write-only

52. In the process structure, the _ _ _ _ _ _ _ _ _ _ _ _ _ _ data contains data elements that are
initialized by the program and may have their values modified during execution of the process.
a. initialized read -write
b. initialized read -only
c. uninitialized
d. initialized write-only

53. A process can obtain its effective user ID by calling the _ _ _ _ _ _ system call.
a. getpid
b. geteuid
c. getppid
d. getpuid

54. A process with an effective user ID of zero is termed as


a. superuser process
b. normal process
c. zombie process
d. orphan process

55. In the process structure, the _ _ _ _ _ _ _ data contains data elements that are initialized by the
program and are read-only while the process is executing.
a. initialized read-write
b. initialized read-only
c. uninitialized
d. initialized write-only

56. The kernel context of a process is maintained and accessible only to the _ _ _ _ _ _ _ _ _ _ _ _ _
_.
a. shell

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 6 of 18

b. kernel
c. user
d. operating system

57. The process ID of the init process is _ _ _ _ _ _ _ _ .


a. 0
b. 2
c. 3
d. 1

58. A process can obtain its PID using the _ _ _ _ _ _ _ _ _ _ _ system call.
a. int pid( );
b. int ppid( );
c. int getpid( );
d. int getppid( );

59. The kernel assigns the parent process ID when a new process is created and a process can obtain
its value using the _ _ _ _ _ _ _ _ _ system call.
a. int pid( );
b. int ppid( );
c. int getpid( );
d. int getppid( );

60. A process can obtain the real user ID of the user executing the process by calling the _ _ _ _ _ _ _
_ _ _ _ system call.
a. pid( );
b. getuid( );
c. getpid( );
d. getppid( );

61. _ _ _ _ _ _ _ _ _ _ _ data structure is used while a unix process is running to allocate more data
space dynamically to the process.
a. stack
b. linked list
c. heap
d. union

62. The _ _ _ _ _ _ _ data structure is used dynamically while the unix process is running to contain
the stack frames that are used by many programming languages.
a. stack
b. linked list
c. heap
d. union

63. The process which is dead but not removed from the process table is
a. zoombie
b. orphan
c. init
d. swapper

64. If the parent process of the exiting process is not executing a wait, the terminating process is
marked as a
a. zoombie
b. orphan
c. init
d. swapper

65. If the parent process has not executed a wait, then the child process becomes a
a. zoombie
b. orphan
c. init
d. swapper

66. The process with process ID 0 is a special process called the _ _ _ _ _ _ _ process.
a. swapper
b. init
c. pagedaemon
d. kernel

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 7 of 18

67. The process with process ID 2 is a special process called the _ _ _ _ _ _ _ process.
a. swapper
b. init
c. pagedaemon
d. kernel

68. _ _ _ _ _ _ _ _ _ _ technique stores the encrypted password in a separate file.


a. password
b. shadow password
c. image password
d. mirror password

69. _ _ _ _ _ _ _ _ _ _ _ _ _ feature allows the system administrator to specify both the minimum and
maximum number of days between password changes for a user.
a. password shadow
b. passwordmin
c. passwordmax
d. password aging

70. The process with process ID 1 is a special process called the _ _ _ _ _ _ _ process.
a. swapper
b. init
c. kernel
d. shell

71. We refer to the process that issues the exec system call as _ _ _ _ _ _ _ .
a. calling process
b. zombie process
c. orphan process
d. init process

72. The attribute that can change when a new program is exceed are
a. process ID
b. terminal group ID
c. real group ID
d. effective user ID

73. A process terminates by calling the _ _ _ _ _ _ _ _ system call.


a. fork
b. exit
c. exec
d. kill

74. _ _ _ _ _ _ _ _ _ system call never returns to the caller.


a. fork
b. exit
c. exec
d. kill

75. The _ _ _ _ _ _ _ _ _ system call replaces the current process with the new program.
a. fork
b. exit
c. exec
d. kill

76. The system call to create a child process is


a. fork
b. exit
c. exec
d. kill

77. The _ _ _ _ _ _ _ _ system call creates a copy of the process that was executing.
a. fork
b. exit
c. exec
d. kill

78. The fork system call is called _ _ _ _ _ _ _ _ _ by the parent process, but it returns _ _ _ _ _ _ _ _
_ _ _ _ once in the parent and once in the child.

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 8 of 18

a. once, once
b. once, twice
c. twice, twice
d. twice, once

79. If the fork system call is not successful, _ _ _ _ _ _ _ is returned.


a. 0
b. 1
c. -1
d. 2

80. The child process differs from the child process in


a. real user ID
b. real group ID
c. effective user ID
d. process ID

81. By pressing Ctrl - key causes the system to send an _ _ _ _ _ _ _ _ _ to the running process.
a. SIGTSTP
b. SIGABRT
c. SIGINT
d. SIGPID

82. By default _ _ _ _ _ _ _ _ _ signal causes the process to immediately terminate.


a. SIGTSTP
b. SIGABRT
c. SIGINT
d. SIGPID

83. Signals can be sent by


a. process to a kernel
b. kernel to a process
c. kernel to kernel
d. shell to a kernel

84. By pressing Ctrl - C key causes the system to send an _ _ _ _ _ _ _ _ _ to the running process.
a. SIGTSTP
b. SIGABRT
c. SIGINT
d. SIGPID

85. By pressing Ctrl - Z key causes the system to send an _ _ _ _ _ _ _ _ _ to the running process.
a. SIGTSTP
b. SIGABRT
c. SIGINT
d. SIGPID

86. A _ _ _ _ _ _ _ _ _ _ _ is a notification to a process that an event has occurred.


a. signal
b. symbol
c. notice
d. function

87. Signals are specified in _ _ _ _ _ _ _ _ _ _ _ header file.


a. stdio.h
b. signal.h
c. sys.h
d. types.h

88. The signal function "SIGCLD" is used for


a. alarm clock
b. bus error
c. death of child process
d. hangup

89. The signal function "SIGHUP" is used for


a. alarm clock
b. bus error
c. death of child process

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 9 of 18

d. hangup

90. The signal function "SIGSYS" is used for


a. bad argument for system call
b. software termination signal
c. trace trap
d. segmentation violation

91. In kill system call, if the pid argument is -1 and sender is not the superuser
a. the signal is sent to all processes, other than the system processes
b. the signal is sent to all processes in the senders process group
c. the signal is sent to all processes whose process group ID equals to absolute value of pid.
d. The signal is sent to all processes whose real user ID equals the effective user ID of the
sending process.

92. In kill system call, if the pid argument is -1 and sender is the superuser
a. the signal is sent to all processes, other than the system processes
b. the signal is sent to all processes in the senders process group
c. the signal is sent to all processes whose process group ID equals to absolute value of pid.
d. The signal is sent to all processes whose real user ID equals the effective user ID of the sending process.

93. The parameters for the kill system call are


a. process ID
b. signal number, time
c. time, process ID
d. process ID, signal number

94. The kill command sends the message to all processes of the callers process group if the pid is
equal to
a. 0
b. 1
c. -1
d. >0

95. In kill system call, if the pid argument is zero, then


a. the signal is sent to all processes, other than the system processes
b. the signal is sent to all processes in the senders process group
c. the signal is sent to all processes whose process group ID equals to absolute value of pid.
d. Error checking is done but no signal is sent.

96. A process can be terminated using _ _ _ _ _ _ _ _ _ command.


a. kill
b. raise
c. alarm
d. abort

97. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ function is used to send a signal to a process or group of process.


a. alarm
b. lseek
c. kill
d. pause

98. A process can send a signal to itself with _ _ _ _ _ _ _ _ _ _ function.


a. kill
b. alarm
c. raise
d. pause

99. The argument for the raise system call is


a. process ID
b. signal number
c. time
d. address

100. In kill system call, if the pid argument is greater than zero, then
a. the signal is sent to all processes, other than the system processes
b. the signal is sent to the process whose process ID is pid
c. the signal is sent to all processes whose process group ID equals to absolute value of pid.
d. Error checking is done but no signal is sent.

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 10 of 18

101. The _ _ _ _ _ _ _ _ _ _ _ function cause the calling process to be suspended until a signal caught
by process and signal handle returns.
a. kill
b. raise
c. sleep
d. abort

102. In alarm function, if the timer expire or dont catch the signal, its default action is
a. to create a process
b. to block a process
c. to suspend a process
d. to terminate the process

103. The _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ function suspends the calling process until a signal is caught.
a. pause
b. kill
c. raise
d. abort

104. The _ _ _ _ _ _ _ _ _ _ _ _ function causes abnormal program termination.


a. pause
b. abort
c. raise
d. sleep

105. The _ _ _ _ _ _ _ _ _ _ _ function causes the calling process to be suspended until the amount of
clock time specified has elapsed.
a. kill
b. raise
c. sleep
d. abort

106. The alarm function causes a _ _ _ _ _ _ _ _ _ _ _ to be sent to the calling process after a specified
number of real time seconds have passed.
a. SIGABRT
b. SIGALRM
c. SIGKILL
d. SIGTERM

107. The default action for SIGALRM is


a. To give alarm
b. to pause the process
c. to terminate the process
d. to create the process

108. The _ _ _ _ _ _ _ _ _ _ system call sends SIGABRT to the process which calls this function.
a. raise
b. kill
c. alarm
d. abort

109. The abort system call sends _ _ _ _ _ _ _ _ _ _ _ _ _ to the process which calls this function.
a. SIGABRT
b. SIGALRM
c. SIGKILL
d. SIGTERM

110. The _ _ _ _ _ _ _ _ _ _ _ function causes a SIGALRM to be sent to the calling process after a
specified number of real time seconds have passed.
a. raise
b. kill
c. alarm
d. abort

111. The process memory manager allocates space to the running process from the _ _ _ _ _ _ _ _
data area.
a. static
b. logical

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 11 of 18

c. unused logical
d. dynamic

112. The data area that are allocated when the program is loaded into memory and remain allocated
the whole time the program is running is
a. dynamic data area
b. static data area
c. logical address space
d. unused logical address space

113. The system call brk( ) returns _ _ _ _ _ _ _ _ _ _ on success.


a. 0
b. 1
c. -1
d. address

114. The system call brk( ) returns _ _ _ _ _ _ _ _ _ _ on failure.


a. 0
b. 1
c. -1
d. address

115. The system call used to allocate the memory


a. brk( )
b. cont( )
c. break( )
d. join( )

116. The part of an operating system that manages memory is called


a. memory manager
b. memory controller
c. memory scheduler
d. memory distributer

117. The process called _ _ _ _ _ _ _ _ _ _ , allocates and deallocates the memory.


a. process manager
b. memory manager
c. device manager
d. resource manager

118. In a system, the only time memory is requested is when a process is created.
a. memory allocation
b. dynamic memory management
c. static memory management
d. memory deallocation

119. In a system, the memory can be requested at any point of time


a. memory allocation
b. dynamic memory management
c. static memory management
d. memory deallocation

120. The highest memory address in a process is called


a. continue
b. higher
c. lower
d. break

121. The malloc( ) function calls _ _ _ _ _ _ _ _ _ _ _ _ function first time and gets a chunk of free
memory.
a. free
b. alloca
c. realloc
d. sbrk

122. Memory is returned to the system when


a. after free( ) is executed
b. upon termination of the application
c. before free( ) is excuted

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 12 of 18

d. after malloc( ) is executed

123. The arguments to be passed to the free( ) function are


a. pointer to the block
b. starting address of the memory
c. ending address of the block
d. size of the memory

124. The _ _ _ _ _ _ _ _ _ function allocates space for an array elements of specified size, and the
space is initialized to zero.
a. malloc
b. calloc
c. realloc
d. free

125. The _ _ _ _ _ _ _ _ _ _ function allocates size bytes of space in the stack frame of the caller, and
returns a pointer to the allocated block.
a. malloc
b. calloc
c. alloca
d. realloc

126. The function used to allocate the memory is called


a. malloc
b. free
c. allocate
d. calloc

127. The function used to release the memory space is


a. malloc
b. free
c. allocate
d. calloc

128. The _ _ _ _ _ _ _ _ _ _ function changes the size of the block pointed to by ptr to size bytes and
returns pointer to the block.
a. malloc
b. free
c. calloc
d. realloc

129. If the space assigned by malloc( ) is overrun, the results are


a. zero
b. one
c. undefined
d. two

130. The calloc( ) function allocates space for an array elements of specified size, and the space is
initialized to
a. empty
b. zero
c. one
d. two

131. The slow system calls are those that


a. Can block forever
b. Cannot be blocked
c. Can block for sometime
d. Which run slowly

132. When the file is closed, the locks on a file are


a. automatically locks are released
b. locks must be explicitly released
c. locks are not released
d. locks are not effected

133. Read locks are examples of


a. shared locks
b. nonshared locks

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 13 of 18

c. unique locks
d. exclusive locks

134. Write locks are examples of


a. shared locks
b. nonshared locks
c. unique locks
d. exclusive locks

135. _ _ _ _ _ _ _ _ _ _ _ _ locks an entire file.


a. record locking
b. range locking
c. file locking
d. record blocking

136. _ _ _ _ _ _ _ _ _ _ _ is the ability of a process to prevent other processes for modifying a region
of a file.
a. record blocking
b. record locking
c. record filing
d. record packing

137. In unix record locking is also called as


a. record locking
b. record filing
c. range locking
d. range blocking

138. The function used to set a lock is


a. lseek
b. flock
c. rlock
d. lockf

139. The function used to test if a lock is set is


a. lseek
b. flock
c. rlock
d. lockf

140. The function to set the record lock is


a. lseek
b. fcntl
c. cntlf
d. flock

141. In the fcntl function, if cmd = F _ SETLK


a. set the lock described by the pointer
b. determine the lock described by the pointer is blocked by some other lock
c. release the lock
d. set the lock after waiting

142. In the fcntl function, if cmd = F _ SETLKW


a. set the lock described by the pointer
b. determine the lock described by the pointer is blocked by some other lock
c. release the lock
d. set the lock after waiting

143. _ _ _ _ _ _ _ _ _ _ occurs when two processes are each waiting for a resource that the other has
locked.
a. encounter
b. deadlock
c. accident
d. blocking

144. _ _ _ _ _ _ _ _ _ _ _ _ _ allows a process to lock a specified portion of a file.


a. file locking
b. record locking
c. mandatory locking

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 14 of 18

d. advisory locking

145. In the fcntl function, if cmd = F _ GETLK


a. set the lock described by the pointer
b. determine the lock described by the pointer is blocked by some other lock
c. release the lock
d. set the lock after waiting

146. Locks are associated with


a. Kernel
b. process
c. users
d. shell

147. When the process is terminated the locks on a file are


a. automatically locks are released
b. locks must be explicitly released
c. locks are not released
d. locks are not effected

148. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ means that the operating system maintains a correct


knowledge of which files have been locked which processes.
a. file locking
b. record locking
c. mandatory locking
d. advisory locking

149. write request to verify that the operation doesnot interfere with a lock held by a process.
a. file locking
b. record locking
c. mandatory locking
d. advisory locking

150. Advisory locks are fine for


a. cooperating processes
b. non cooperating processes
c. parallel processes
d. single process

151. A _ _ _ _ _ _ _ _ _ _ object remains in existence until the kernel reboots or until the object is
explicitly deleted.
a. Kernel - persistent IPC
b. Filesystem - Persistent IPC
c. Process - Persistent IPC
d. Persistent IPC

152. An example of Process - Persistent IPC object


a. message queues
b. semaphores
c. pipes
d. shared memory

153. A _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ object remains in existence until the last process that holds
the object open close the object.
a. Kernel - persistent IPC
b. Filesystem - Persistent IPC
c. Process - Persistent IPC
d. Persistent IPC

154. A _ _ _ _ _ _ _ _ _ _ object remains in existence until the kernel reboots.


a. Kernel - persistent IPC
b. Filesystem - Persistent IPC
c. Process - Persistent IPC
d. Persistent IPC

155. A _ _ _ _ _ _ _ object remains in existence until the object is explicitly deleted.


a. Kernel - persistent IPC
b. Filesystem - Persistent IPC
c. Process - Persistent IPC

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 15 of 18

d. Persistent IPC

156. Unix Pipe means


a. output at one end becomes output at the other end
b. character being passed from one process to another process
c. input at one end becomes output at the other end
d. input at one end becomes input at the other end

157. $cat xyz | more


a. displays contents of file xyz page by page
b. displays contents of file xyz
c. creates a file xyz
d. concatenates the files xyz and more

158. Pipe system call returns


a. 1 file descriptor
b. 2 file descriptors
c. 3 file descriptors
d. 4 file descriptors

159. Pipes are created at


a. user space
b. shell
c. program space
d. kernel space

160. Unamed pipes will be destroyed


a. as soon as the process that creates pipe terminates
b. permanent fixture
c. as soon as the process creates another pipe
d. when process blocks at one side

161. Named pipes are


a. local variables
b. static variables
c. constant variables
d. global variables

162. Once a FIFO is created, it must be opened for reading or writing using _ _ _ _ _ _ _ _ _ _ _ _ _ _
system call.
a. read
b. write
c. open
d. close

163. Named pipes will be opened only when


a. when process block at one side
b. when process blocks to both sides
c. permanent fixture
d. when process is unblocked

164. Advantage of named pipes over pipes


a. permanent fixture
b. as soon as the process that creates pipe terminates
c. as soon as the process creates another pipe
d. when process blocks at one side

165. Named pipes are examples of _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ IPC object.


a. Kernel - persistent IPC
b. Filesystem - Persistent IPC
c. Process - Persistent IPC
d. Persistent IPC

166. System call to create named pipe


a. create pipename
b. mknod pipename p
c. pipe pipename p
d. makepipe pipename p

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 16 of 18

167. Named pipes are also called as


a. FIFOs
b. Semaphores
c. Shared Memory
d. Message Queues

168. FIFOs are also called as


a. Named Pipes
b. Semaphores
c. Shared Memory
d. Message Queues

169. A FIFO is created by _ _ _ _ _ _ _ _ _ _ system call.


a. Fork
b. Mknod
c. raise
d. create

170. ls - l shows named pipe with _ _ _ _ _ _ _ _ character at beginning.


a. P
b. S
c. C
d. Z

171. In semget( ) function, if flag = IPC _ CREAT IPC _ EXCL then


a. if semaphore doesnot exist , it gives an error
b. if semaphore is not there it creates semaphore and returns ID
c. if semaphore is not there it creates semaphore and doesnot return ID
d. if semaphore is already exists, it deletes.

172. In the semaphore function semget(key, nsem, IPC _ PERM ; nsem argument specifies _ _ _
_____
a. key of semaphore
b. permissions of semaphores
c. number of sub semaphores
d. number of flags in the semaphore

173. The function semget( ) is used to


a. to create semaphore
b. to delete semaphore
c. to update semaphore value
d. to read the semaphore value

174. The function semctl( ) is used


a. to delete semaphore
b. to block a semaphore
c. to rename a semaphore
d. to create semaphore

175. To see the list of semaphores already existing in the system, the command is
a. ipcs - p
b. ipcs - s
c. ipcs - q
d. ipcs - r

176. Semaphores are stored in


a. user space
b. kernel space
c. shell
d. hardware

177. In binary semaphore, value of semaphore = 0


a. resource is locked
b. resource is available
c. resource is removed
d. resource is added

178. In binary semaphore, value of semaphore = 1

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 17 of 18

a. resource is locked
b. resource is available
c. resource is removed
d. resource is not available

179. The value of binary semaphores ranges between


a. zero and infinity
b. infinity and zero
c. zero and one
d. zero and some limit

180. The value of semaphore in count semaphore is


a. zero and infinity
b. infinity and zero
c. zero and one
d. zero and some limit

181. In msgctl( ) function, if cmd = IPC _ RMID then


a. it gets the status of message queue
b. it removes the message queue
c. it sets the members of message queue
d. it receives message from a queue

182. In msgctl( ) function, if cmd = IPC _ SET then


a. it gets the status of message queue
b. it removes the message queue
c. it sets the members of message queue
d. it receives message from a queue

183. When message queue is created, the fields of message queue msg _ qnum, msg _ lspid, msg _
lrpid, msg _ stime and msg _ rtime are set to
a. 1
b. 0
c. 2
d. infinity

184. The purpose of msgctl( ) function is


a. to access the member of message queue
b. to create message queue
c. to send a message queue
d. to receive message from a queue

185. In msgctl( ) function, if cmd = IPC _ STAT then


a. it gets the status of message queue
b. it removes the message queue
c. it sets the members of message queue
d. it receives message from a queue

186. The purpose of the function msgsnd( ) is


a. to access the member of message queue
b. to create message queue
c. to send a message queue
d. to receive message from a queue

187. The purpose of the function msgget( ) is


a. to access the member of message queue
b. to create message queue
c. to send a message queue
d. to receive message from a queue

188. The purpose of the function msgctl( ) is


a. to kill a message queue
b. to create message queue
c. to send a message queue
d. to receive message from a queue

189. The purpose of the function msgrcv( ) is


a. to access the member of message queue
b. to create message queue

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08


UNIX Programming Page 18 of 18

c. to send a message queue


d. to receive message from a queue

190. The function to kill a message queue


a. msgrcv( )
b. msgget( )
c. msgsnd( )
d. msgctl( )

191. In function shmctl( ), the cmd is IPC _ SET specifies


a. to remove shared memory area
b. to set the shared memory structure shmid _ ds
c. to get the status of shared memory from shmid _ ds
d. to build the shared memory area

192. In function shmctl( ), the cmd is IPC _ STAT specifies


a. to remove shared memory area
b. to set the shared memory structure shmid _ ds
c. to get the status of shared memory from shmid _ ds
d. to build the shared memory area

193. For every shared memory segment , the kernel maintains the _ _ _ _ _ _ _ _ _ _ _ _ structure
a. msqid _ ds
b. shmid _ ds
c. shmmem _ ds
d. memsh _ ds

194. If shmid= shmget(key, 10, IPC _ CREAT | 0666); in this the size of shared segment is
a. 10 bytes
b. 0666
c. 10 Kilobytes
d. 10 Megabytes

195. In function shmctl( ), the cmd is IPC _ RMID specifies


a. to remove shared memory area
b. to set the shared memory structure shmid _ ds
c. to get the status of shared memory from shmid _ ds
d. to build the shared memory area

196. _ _ _ _ _ _ _ _ _ _ _ _ is a way of allowing two or more processes to work on the same area in
memory.
a. pipe
b. shared memory
c. semaphore
d. message queue

197. The function to create a shared segment


a. shmget
b. shmat
c. shmdt
d. shmput

198. The function to attach the shared segment to the user process is
a. shmget
b. shmat
c. shmdt
d. shmput

199. The function to detach the shared segment from the user process is
a. shmget
b. shmat
c. shmdt
d. shmput

200. For using a shared memory segment the header file to be include is
a. <sys/msg.h>
b. <sys/sem.h>
c. <sys/pipe.h>
d. <sys/shm.h>

file://C:\Documents and Settings\Raghav\Desktop\3-2ITnew\3-2IT\3-2 IT\UNIX Program... 16-Apr-08

You might also like