0% found this document useful (0 votes)
92 views31 pages

QUIZ Answer Merged

The document contains quiz questions and answers related to processes and files in UNIX/Linux systems. Some key points covered include: - A process is an instance of a running program and passes through states like born, running, and terminated. - Common process attributes shown by the 'ps' command include PID, PPID, time, and command. - Files in UNIX are divided into ordinary, directory, and device files. Directory files contain metadata about other files. - Common file-related commands include 'cd' to change directories, 'mkdir' to create directories, and 'touch' to create empty files.

Uploaded by

Piyush Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views31 pages

QUIZ Answer Merged

The document contains quiz questions and answers related to processes and files in UNIX/Linux systems. Some key points covered include: - A process is an instance of a running program and passes through states like born, running, and terminated. - Common process attributes shown by the 'ps' command include PID, PPID, time, and command. - Files in UNIX are divided into ordinary, directory, and device files. Directory files contain metadata about other files. - Common file-related commands include 'cd' to change directories, 'mkdir' to create directories, and 'touch' to create empty files.

Uploaded by

Piyush Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

QUIZ-1

1. A process is an instance of _______ program.


a) waiting
b) executing
c) terminated
d) halted
Answer: b
Explanation: A process is simply an instance of a running program. A process passes through many
states throughout its life cycle i.e. when it is born until it is executed. After the process has completed
it is said to be terminated.
2. A process is said to be ____ when it starts its execution.
a) born
b) die
c) waiting
d) terminated
Answer: a
Explanation: A process is said to be born when it starts its execution. It is the initial state of a
process. The process is assigned to CPU for its execution further.
3. When the process has completed its execution it is called ______
a) born
b) terminated
c) waiting
d) exit
Answer: d
Explanation: A process is said to be died or terminated when it has completed its execution either
normally or abnormally. As long as the process is running it is in an active state but as soon as the
process has completed its execution, the process is said to die.
4. The parent id of a child is called ______
a) PID
b) PPID
c) TID
d) PTID
Answer: b
Explanation: The parent ID of a child process is called PPID (parent process ID) and is available as a
process attribute. It is common that several processes have the same parent. When several processes
have the same parent, it often makes sense to kill the parent process rather than killing each child
separately.
5. To know the PID of your current shell, which command will be used?
a) echo $$
b) echo $
c) $SHELL
d) $PATH
Answer: a
Explanation: The shell’s pathname is stored in SHELL, but it’s PID is stored in a special variable, $$.
To know the PID of our current shell, type
$ echo $$
258 // PID of the current shell

QUIZ-2
1. Which of the following command doesn’t create a process?
a) pwd
b) fork
c) cd
d) pwd and cd
Answer: d
Explanation: When we run a command, a process representing the command is started by the shell
process but all commands don’t set up processes. Built-in commands of the shell like pwd, cd etc do
not create processes.
2. Which command shows some attributes of a process?
a) pid
b) $$
c) ps
d) HOME
Answer: c
Explanation: ps command is used to show some attributes of a process. This command reads through
the kernel’s data structures and process tables to fetch the characteristics of a process. By default, ps
command displays the processes owned by the user running the command.
3. Which of the following attribute is not shown by ps command?
a) PID
b) PPID
c) tty
d) size
Answer: d
Explanation: ps command displays the processes owned by the user running the command. If we
execute the command immediately after logging in, it may produce an output like this:
$ ps
PID TTY TIME CMD
291 console 0:00 bash // login shell of this user
4. Which option is used by ps command to get a detailed listing of process attributes?
a) -u
b) -f
c) -l
d) –x
Answer: b
Explanation: ps is a highly variant command; its actual output varies across different flavours. To get
a detailed listing of process attributes along with PPID and owner (UID), we have to use the -f option
with ps command. For example,
$ ps -f
UID PID PPID C STIME TTY TIME CMD
Abd 367 291 0 12:35:16 console 0:00 vi create_user.sh
Ryan 291 1 0 10:24:58 console 0:00 -bash
5. Which option is used by the system administrator for displaying processes of a user?
a) -f
b) -u
c) -a
d) –e
Answer: b
Explanation: The system administrator needs to use the -u (user) option to know the activities of a
user. For example,
$ ps -u
PID TTY TIME CMD
378? 0:05 Xsession
339 pts/3 0:00 bash
460 pts/5 0:00 dtsession
478 pts/5 0:00 vi

QUIZ-3
1. Which command is used to display the octal value of the text
a) octal
b) text_oct
c) oct
d) od
Answer: d
2. Which command is used to view compressed text file contents
a) cat
b) type
c) zcat
d) print
Answer: c
3. Which command changes a file’s group owner
a) cgrp
b) chgrp
c) change
d) group
Answer: b
4. Which command is used to extract intermediate result in a pipeline
a) tee
b) extract
c) exec
d) none of the mentioned
Answer: a
5. Which command is used to extract a column from a text file
a) paste
b) get
c) cut
d) tar
Answer: c
6. Which command is used to display disk consumption of a specific directory
a) du
b) ds
c) dd
d) dds
Answer: a
7. Which command is used to perform backup in unix?
a) backup
b) cpio
c) zip
d) gzip
Answer: b
8. Which command creates an empty file if file does not exist?
a) cat
b) touch
c) ed
d) read
Answer: b
9. Which option of rm command is used to remove a directory with all its subdirectories
a) –b
b) –o
c) –p
d) –r
Answer: d
10. Which command is used to identify file type?
a) Type
b) File
c) Finfo
d) Info
Answer: b

QUIZ-4
1. In how many broad categories, files are divided into UNIX?
a) 2
b) 4
c) 5
d) 3
Answer: d
Explanation: Files are divided into three major categories i.e. ordinary file, directory file and device
file. The characteristics of these three categories of files differ from each other and each category has
a predefined use.
2. The most common file type is ___
a) ordinary file
b) directory file
c) device file
d) ordinary file and directory file
Answer: a
Explanation: The most common file type is an ordinary file or a regular file. It contains data as a
stream of characters. Ordinary files are also of two types, text file and binary file.
3. What is a directory file?
a) a directory containing data
b) a directory containing details of the files and subdirectories it contains
c) a directory contains files
d) a directory containing data and files
Answer: b
Explanation: A directory file contains no data but some details of the subdirectories and files that it
contains. Directory files contain an entry for every file and subdirectory in it and each entry has some
necessary information regarding files and subdirectories.
4. Each entry of directory file has component(s) namely _____
a) filename
b) inode number
c) filename and inode number
d) file size

Answer: c
Explanation: Every entry of the directory file contains information about files and subdirectories and
each entry has two components:
-> Filename
-> A unique identification number (called inode number).
5. When we log in, the UNIX places us in a directory, called ______ directory
a) home
b) main
c) parent
d) current

Answer: a
Explanation: When we log in, the system automatically places us in a directory called Home
directory. We can change our directory if we want and can also view our home directory using the
shell variable, HOME.
6. The root directory is represented by ___
a) \
b) /
c) *
d) $

Answer: b
Explanation: The root directory (/) serves as a reference point for all the files. All the files are
hierarchically below it. All files in UNIX are related to one another. The file system in UNIX is a
collection of all these related files (ordinary, directory and device files) organized in a hierarchical
manner.
7. _____ and _____ cannot be used in a filename.
a) /, NULL
b) $,^
c) ., %
d) NULL, $
Answer: a
Explanation: UNIX imposes no rules in framing filename extensions but there are some special
characters that cannot be used while naming a file. / and NULL are the characters that cannot be used
in a filename.
8. Which command is used for changing the current directory?
a) cd
b) cp
c) pwd
d) rm

Answer: a
Explanation: cd (change directory) command is used for moving around the file system. cd command
is usually invoked with a argument. After invocation, it changes the current directory to the directory
specified as argument. Cp command is used for copying files while rm command is used for deleting
files.
For example: our current directory is /bin/user06 and we want to change our directory to a directory
named dir_one which is inside the user06 directory. To do so, type the following:
$ cd dir_one
$pwd
/bin/user06/dir_one
9. Which command is used for creating directories?
a) rmdir
b) mkdir
c) cd
d) cp

Answer: b
Explanation: Directories in UNIX are created using mkdir command. The name of the directory to be
created is specified as an argument to the mkdir command. For example, to create a dir named dir_01
in the current directory we can use the following command,
$ mkdir dir_01
10. What does the following command do? $ mkdir dir dir/dir_01/dir_02
a) create dir, dir_01 and dir_02
b) creates dir_02
c) creates dir only
d) throws an error

Answer: a
Explanation: The above command first creates a directory named dir and after that it creates a
subdirectory dir_01 under dir. At last, it creates another subdirectory dir_02 under dir_01. Thus a
directory tree is formed in which directory dir is the parent directory and dir_01, dir_02 are
subdirectories.
11. Sometimes we are unable to create a directory because ______________
a) the directory may already exist in the current directory
b) there may be an ordinary file by the same name in the current directory
c) the permissions set for the current directory does not allow the creation
d) the directory may exist, there may be an ordinary file, the permissions set for the current directory
does not allow the creation

Answer: d
12. Which command is used for removing an empty directory?
a) mkdir
b) rmdir
c) del
d) remove

Answer: b
Explanation: rmdir command is used for removing directories provided the directory should be
empty. For example, to remove a directory named dir_001 in the current directory type the following
command on the terminal.
$ rmdir dir_001
13. If rmdir dir001 fails, what could be the reason(s)?
a) dir001 doesn’t exist
b) dir001 is not empty
c) permissions of dir001 doesn’t allow to remove it
d) dir001 doesn’t exist, dir001 is not empty and permissions of dir001 doesn’t allow to remove it

Answer: d
Explanation: There could be multiple reasons which could lead to failure while removing a directory.
Major reasons could be:
-> directory doesn’t exists.
-> directory is not empty.
-> permissions of directory doesn’t allow to remove it.
14. All UNIX and LINUX systems have one thing in common which is ____
a) set of system calls
b) set of commands
c) set of instructions
d) set of text editors

Answer: a
Explanation: As we know UNIX and LINUX systems have one thing in common; they use the same
set of system calls.
15. Which of the following mode is used for opening a file in both reading and writing?
a) O_RDONLY
b) O_WRONLY
c) O_RDWR
d) O_WDR
Answer: c
Explanation: There are three modes of opening a file namely:
O_RDONLY - opens files for reading
O_WRONLY - opens file for writing
O_RDWR - opens file for reading and writing

QUIZ-5
1. Which command is used to display and create files?

A. cat

B. vi

C. ed

D. lyrix
Answer: Option A

2. The second set of the three permissions (r-) indicates that

A. group has read permission only

B. other has read permission only

C. owner has read permission only

D. group has write permission only


Answer: Option A

3. Which column contains all details of the permissions of a file when you issue the ls -l
command?

A. second

B. fourth

C. third

D. first
Answer: Option D

4. Which of the following commands is used to display your working directory?

A. dir

B. prompt $p$g

C. pwd

D. path
Answer: Option C
5. The command used to compare the files is known as
A. comp
B. cmp
C. do
D. ccp
Answer: Option B
6. Which command is used to terminate a process?
A. shutdown
B. haltsys
C. cancel
D. kill
Answer: Option D
7. The cp command uses:
A. standard input file
B. standard output file
C. both input and output file
D. neither standard input nor standard output file
Answer: Option D
8. Which of the following special shell variables is used to process number of the last
background job?
A. $!
B. $#
C. $0
D. $*
Answer: Option A
9. Which of the following is not a filter?
A. cat
B. grep
C. wc
D. sort
E. None of the above
Answer: Option E
10. Which command is used to change directory to the name beginning with a 'p'?
A. cd p
B. cd p?
C. cd p*
D. cd [p]
Answer: Option C
11. The Unix shell is both _______ and _______ language.
a) interactive, responsive
b) interpreter, executing
c) scripting, interpreter
d) high level, low level
Answer: c
Explanation: The UNIX shell is both an interpreter and scripting language. We can also say that shell
can be interactive or non-interactive. When we log in to our system, interactive shell presents a
prompt and wait for our requests while a non-interactive shell is managed by an interactive shell
while executing a shell script.

12. Which of the following is not true about Unix?

a. Many people can use a UNIX based computer at the same time; hence UNIX is called as a
multiuser system

b. A user can run multiple programs at the same time; hence UNIX is called a multitasking
environment.

c. UNIX was not written in ‘C’ language

d. Linux is also known as a version of UNIX

Answer: (c).

13. Which part of the Unix operating system interacts with the hardware?
a) Kernel
b) Shell
c) vi editor
d) application program

Answer: a
Explanation: The kernel is the core of the operating system. It is a collection of routines written
in C which directly communicates with the hardware. User programs that need to interact with
the hardware access the services of the kernel. There is only one kernel running on a system,
unlike shells which can be multiple.

14. What is a shell script?


a) group of commands
b) a file containing special symbols
c) a file containing a series of commands
d) group of functions
Answer: c
Explanation: When we have to execute a series of commands altogether, we store them in a
file which is itself executed as a shell script. A shell script is basically a computer program
designed to be run by the UNIX shell.

QUIZ-6

1. What is true about pipes in unix?


A. Pipe can connect two commands together so that the output from one program
becomes the input of the next program
B. To make a pipe, put a hash (#) on the command line between two commands.
C. Two or more commands connected in this way form a pipe.
D. Both A and C
Ans : D
2. To make a pipe, put a ________ on the command line between two
commands.
A. |
B. /
C. \
D. $
Ans : A
3. Which command searches a file or files for lines that have a certain
pattern?
A. erep
B. pgrp
C. grep
D. drep
Ans : C
4. What does -c operation do in grep command?
A. Matches either upper or lowercase.
B. Prints only the count of matching lines.
C. Prints the matched line and its line number.
D. Prints all lines that do not match pattern.

Ans : B
5. Which command is used to arranges lines of text alphabetically or
numerically?
A. sort
B. psort
C. asort
D. series
Ans : A
6. Which option is used ignores first x fields when sorting?
A. -x
B. +x
C. -X
D. +X
Ans : B
7. If there are special characters in a pattern, then we've to enclose them in
______
A. single quotes
B. double quotes
C. Without any quotes
D. None of the above
Ans : B
8. POSIX identifies regular expressions as belonging to ____ categories.
A. 2
B. 3
C. 4
D. 5
Ans : A
9. Which of the following is not filter in unix?
A. cat
B. head
C. tail
D. cd
Ans : D
10. Which of the following filter is used to remove duplicate lines?
A. cat
B. sed
C. uniq
D. grep
Ans : C
11. The basic building blocks of Unix permissions are ____________.
A. read
B. write
C. execute
D. All of the above
Ans : D
12. How many types of permissions a file has in UNIX?
A. 2
B. 3
C. 4
D. 5
Ans : B
13. What is group ownership?
A. group of users who can access the file
B. group of users who can create the file
C. group of users who can edit the file
D. group of users who can delete the file
Ans : A

14. Which number is assign to read permission in Octal Permission


Representation?
A. 0
B. 1
C. 2
D. 4
Ans : D
15. Which file access mode grants the capability to modify, or remove the
content of the file?
A. Read
B. Write
C. Execute
D. All of the above
Ans : B
QUIZ -7
1. What is output of below program?
int main()
{ for(; ;);
for(; ;);
printf("Hello");
return 0;
}

(A) Compilation Error


(B) Runtime Error
(C) Nothing is printed
(D) Hello is printed infinite times

Ans: C

Blank for loop with ; ; is always infinite loop. printf() will never executed in this program.

2. What is the output of below program?


int main()
{
for(; ;)
for(; ;)
printf("Hello..");

return 0;
}
(A) Compilation Error
(B) Runtime Error
(C) Hello is printed one time
(D) Hello is printed infinite times
Ans: D
Always remember, a for loop with only two ; is infinite loop. And it is because there is no
initialization, condition & increment/decrements
3. What is the meaning of below lines?
void sum (int, int);

(A) sum is function which takes int arguments


(B) sum is a function which takes two int arguments and returns void
(C) it will produce compilation error
(D) Can't comment

Ans: B
4. The concept of two functions with the same name is known as?

(A) Operator Overloading


(B) Function Overloading
(C) Function Overriding
(D) Function renaming

Ans: B

5. Can we declare function inside structure of C Programming?

(A) Yes
(B) No
(C) Depends on Compiler
(D) Yes but run time error

Ans: B

6. Which of the following is executed by Preprocess?

(A) #include<stdio.h>
(B) return 0
(C) void main(int argc , char ** argv)
(D) None of above

Ans: A

7. Is it possible to return two values by any function?

(A) Yes

(B) No

Ans: B

Function can return only one value. If you want to return group of values then create a structure
and return it.

8. Is it possible to run program without main() function?

(A) Yes

(B) No

Ans: B
Ideally No but remember pragma directives allows few function to be executed before and after
main() function

9. What is sizeof() in C?

(A) Operator
(B) Function
(C) Macro
(D) None of these

Ans: A

10. Is it true that a function may have several declaration, but only one definition?

(A) True

(B) False

Ans: A

Declaration like int sum(int, int); is allowed number of times but definition int sum(int a, int b) {
return a+b; } is allowed only one time. Multiple definition of same function is compilation error
( redefinition error )

11. Will compiler produce any compilation error if same header file is included two times?

(A) Yes
(B) No

Ans: B

12. Which one of the following is an invalid macro in C programming?

(A) #pragma
(B) #error
(C) #ifndef
(D) #elseif

Ans: D

13. Which compilation unit is responsible for adding header files contained in the source code?

(A) Linker
(B) Compiler
(C) Assembler
(D) Preprocessor
Ans: D

14. int num[10] = {3, 3, 3};

Which of the following statement is correct?

A. num[9] is the last element of the array num


B. The value of num[8] is 3
C. The value of num[3] is 3
D. None of the above

Answer: (a) num[9] is the last element of the array num

Explanation: The num[9] is the last element of the array number because the total element in this
array is 10, and the array starts with 0, so the last element of the array is the num[9].

15. If p is an integer pointer with a value 1000, then what will the value of p + 5 be?

a) 1020
b) 1005
c) 1004
d) 1010

Ans: a)

Since size of an integer is 4bytes, p + 5 will be at value 1000+5 * 4 = 1020.


QUIZ -8
1. How to find the length of an array in C?
a) sizeof(a)
b) sizeof(a[0])
c) sizeof(a) / sizeof(a[0])
d) sizeof(a) * sizeof(a[0])
Ans: C
sizeof operator returns the memory accessed by the variable within it. The total memory
accessed by the array divided by memory accessed by its individual element will give the length
of the array.
2. Which of the following will occur if we call the free() function on a NULL pointer?
a) Compilation Error
b) Runtime Error
c) Undefined Behavior
d) The program will execute normally.
Ans: D
Calling the free() function on a NULL pointer is totally valid and will not cause any error.
3. Which of the following should be used to free memory from a pointer allocated using the
“new” operator?
a) Free
b) Delete
c) realloc()
d) None of the above
Ans: B
The delete keyword is used to free memory from a pointer allocated using the new keyboard.
4. The type cast operator is
a) (type)
b) cast()
c) (;;)
d) // ” “

Ans: A
5. p++ executes faster than p+1 because
a) p uses registers
b) p++ is a single instruction
c) ++ is faster than +
d) None of these

Ans: B
6. Which of the following statements is true?
a) C Library functions provide I/O facilities
b) C inherent I/O facilities
c) C doesn’t have I/O facilities
d) Both (a) and (c)

Ans: A
7. Which pair of functions below are used for single character I/O.
a) Getchar() and putchar()
b) Scanf() and printf()
c) Input() and output()
d) None of these

Ans: A
8. If one or more structure are other structures, then the structure is known as
(A) Nested structure
(B) Structured structure
(C) Invalid structure
(D) Self referential structure
Ans: A
9. Every string must be terminated by
(A) Linefeed character
(B) Null character
(C) Newline character
(D) Carriage return character
Ans: B
10. The __ is a program that links the object code of the program with the library function
code that is necessary for the program to run.
(A) C linker
(B) Compiler
(C) C compiler
(D) Editing
Ans: A
11. Which of the following statement about functions of false?
(A) A function can call itself.
(B) A function can call another function.
(C) Constants can appear in the formal argument list.
(D) More than one function is allowed in a program unit.
Ans: C
12. A pointer is
A. A keyword used to create variables
B. A variable that stores address of an instruction
C. A variable that stores address of other variable
D. All of the above
Ans: C
13. Point out the error in the program?
struct emp
{
int ecode;
struct emp *e;
};
a. Error: in structure declaration
b. Linker Error
c. No Error
d. None of above
Ans: C
This type of declaration is called as self-referential structure. Here *e is pointer to a struct
emp.
14. What should be the expression return value for a do-while to terminate
a) 1
b) 0
c) -1
d) NULL
Answer: (b)
15. When the main function is called, it is called with the arguments
a) argc
b) argv
c) None of these
d) both a & b
Answer: (d)
QUIZ -9
1. In a system call
i. A service request to the operating system
ii. The normal flow of the operating system is interrupted
iii. The control is given to the operating system
iv. The system is calling for resources
a) iii and iv only
b) i and iii only
c) i, ii and iii
d) all of the above
Ans: c
2. #include <unistd.h>
int pipe(int fildes[2]);
Describe pipe()
a) If successful, pipe returns 1. If unsuccessful, pipe returns –1 and sets errno. The pipe
function described here creates a traditional unidirectional communication buffer, where
fields[0] used for read and fields[1] used for write
b) If successful, pipe returns 0. If unsuccessful, pipe returns 1 and sets errno. The pipe
function described here creates a traditional unidirectional communication buffer, where
fields[0] used for read and fields[1] used for write
c) If successful, pipe returns 0. If unsuccessful, pipe returns –1 and sets errno. The pipe
function described here creates a traditional unidirectional communication buffer, where
fields[0] used for write and fields[1] used for read
d) If successful, pipe returns 0. If unsuccessful, pipe returns –1 and sets errno. The pipe
function described here creates a traditional unidirectional communication buffer, where
fields[0] used for read and fields[1] used for write
Ans: d
3. Choose the correct statements.
a) Any process has an associated owner ID and group ID
b) Effective ID defines who you are for the duration of a process
c) Real ID defines who you are for the duration of a process
d) Both (a) & (b)
Ans: d
4. To simulate any of the system commands, which of the system calls - fork, wait, and excel are
required to be used?
a) fork and wait
b) fork, wait, and execl
c) fork and excel
d) wait and excel
Ans: b
5. Choose the correct statements.
a) C programs can directly make system calls
b) Library functions use system call
c) Both (a) and (b)
d) Only (a) not (b)
Ans: c
6. In which cases(s) fork system call will fail.
a) The limit on the maximum number of processes in the system would be exceeded.
b) The limit on the maximum number of processes that can be under execution by a single user
would be exceeded.
c) Both (b) & (c)
d) Neither (a) nor (b)
Ans: c
7. Select the correct statement(s)
(i) An open file descriptor in a Unix process is an integer.
(ii) Two Unix processes may simultaneously have open file descriptors that refer to the same
open file description.
(iii) Two open file descriptions in the same Unix processes may refer to the same file.
(iv) When a file is closed the corresponding open file description is de-allocated.
a) All are correct
b) (i), (ii) and (iii) are correct
c) (i) and (ii) are correct
d) (ii) and (iii) are correct
Ans: b
8. When a process is forked the child process inherits some properties. Which of the following
properties are inherited?
i. The process id.
ii. The process code
iii. All the defined program variables
iv. The stack
a) Everything
b) All except i and iii
c) All except i
d) All except iv
Ans: c
9. Which of the following is correct for pipe()
(i) When a pipe is defined – its either end can be utilized for reading / writing
(ii) The named pipes are behaving like a file, where you can read or write data trough some
process.
a) All are correct
b) Only (i)
c) Only (ii)
d) Neither (i) nor (ii)
Ans: c
10. Which one of the following is different than the other?
a) Shared Memory
b) Semaphore Set
c) Pipe
d) Message Queue
Ans: c
11. The Blocked process comes in running state through which state?
a) New
b) Ready
c) Done
d) None of the above
Ans: b
12. A semaphore is an variable with_________ atomic operations.
a) One
b) Two
c) Three
d) Four
Ans: b
13. WNOHANG in waitpid() means
a) Parent will wait for any arbitrary child
b) Parent will wait for a specific child
c) Parent does not wait if child does not terminate just check and return waitpid()
d) None of the option
Ans: c
14. Which of the following system calls does not return control to the calling Point, on
termination?
a) fork()
b) wait()
c) waitpid()
d) exec
Ans: d
15. To run the script, we should make it executable first by using _____
a) chmod +x
b) chmod +w
c) chmod +r
d) None of the above
Ans: a
1. How key can be generated in IPC in POSIX standard.
(i) IPC_PRIVATE
(ii) Pick a key randomly
(iii) Using ftok()
a) Using (i) and (ii)
b) Using (i) and (iii)
c) Only (iii)
d) All of the above
Ans: D

2. Select the correct statement(s)


(i) An open file descriptor in a Unix process is an integer.
(ii) Two Unix processes may simultaneously have open file descriptors that
refer to the same open file description.
(iii) Two open file descriptions in the same Unix processes may refer to the
same file.
(iv) When a file is closed the corresponding open file description is de-
allocated.
a) All are correct
b) (i), (ii) and (iii) are correct
c) (i) and (ii) are correct
d) (ii) and (iii) are correct
Ans: B

3. Which of the following statement(s) are correct


(i) Thread creation and thread synchronization can be done with less execution
time overhead if threads are implemented at the kernel level.
(ii) Threads that are implemented at the kernel level are likely to be more able
to take advantage than threads that are implemented only at the library/user
level.
(iii) All the threads in a process share access to the same set of open files (i.e.,
the same mapping of open file descriptors to open file descriptions).

a) (i) and (ii)


b) (i) and (iii)
c) (ii) and (iii)
d) all are correct
Ans: C

4. How key can be generated in IPC in POSIX standard.


(i) IPC_PRIVATE
(ii) Pick a key randomly
(iii) Using ftok()
a) Using (i) and (ii)
b) Using (i) and (iii)
c) Only (iii)
d) All of the above
Ans : D

5. How many hello world will be printed by the below code:


fork() || fork() && fork() && fork();
Fprintf(stderr,"Hello, World!\n");
a) 4
b) 5
c) 6
d) 8
Ans: A

6. What will be the value of fd1 and fd2:


int fd1 = open("fool1.txt", O_RDONLY | O_CREAT);
int fd2 = open(".\fool2.txt", O_RDONLY | O_CREAT);
a) 3, -1
b) 3, 4
c) 2, 3
d) 3, 3
Ans: A

7. What will be the final value of fd1 :


int fd1 = open("fool1.txt", O_RDONLY | O_CREAT);
close(fd1);
int fd1 = open(".\fool2.txt", O_RDONLY | O_CREAT);
a) 0
b) 1
c) 2
d) 3
Ans: D

8. The pipe function required which library


a) #include <unistd.h>
b) # include <sys/types.h>
c) #include <fcntl.h>
d) #include <pipe.h>
Ans: A

9. A semaphore is a shared integer variable __________


a) That can not drop below zero
b) That can not be more than zero
c) That can not drop below one
d) That can not be more than one
Ans: A

10. What will be the numberic equivalent of the following file permission:
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
a) 464
b) 446
c) 644
d) 640
Ans: C
1. To enforce ………………….. two functions are provided enter-critical and exit-critical,
where each function takes as an argument the name of the Resource that is the
subject of competition.
a) Starvation
b) Synchronization
c) Deadlock
d) Mutual Exclusion
Ans: D

2. Pipe is useful for communication among


a) related processes
b) unrelated processes
c) system process and user process
d) any two processes
Ans: A

3. Which one of the following is not shared by threads?


a) Program counter
b) Stack
c) Both program counter and stack
d) None
Ans: C

4. Thread synchronization is required because ___________


a) all threads of a process share the same address space
b) all threads of a process share the same global variables
c) all threads of a process can share the same files
d) all of the mentioned
Ans: D

5. Which IPC is nonvolatile (in the sense that they do not disappear even if no process
has them open?)
a) Pipes
b) FIFO
c) Semaphore
d) Message Queue
Ans: B

6. Choose the correct explaination of dup() system call.


a) Used to copy a file
b) Create duplicate files
c) Copy a file descripter
d) Change a file descripter
Ans: C

7. Choose the option that happens after executing dup2(int fildes, int fildes2); //
a) fildes is closed
b) fildes2 is closed
c) both file descripters are closed
d) none of the file descripters are closed
Ans: B

8. A FIFO is
a) A file with a name and permissions
b) A file with name but without permissions
c) A file without name but with permissions
d) A file without name and permissions
Ans: A

9. Select the correct usage of pipe() with fork()


a) Call fork() and use pipe() as a parameter,
b)Call pipe() and use fork() as a parameter
c) call pipe() before calling fork()
d) call fork() before calling pipe()
Ans: C

10. File descripter for standard error is ___


a) 0
b) 1
c) 2
d) Can be any number except 0, 1, & 2.
Ans: C

You might also like