Tuesday, 15 June 2021

os viva question for linux

1. Create a read-only file in your home directory?

This is a UNIX command where you need to create a file and change its parameter to read-only by using chmod command you can also change your umask to create read only file. $touch file $touch 400 file

2.How do you find how many cpu are in your system and there details?

By looking into file /etc/cpuinfo for example you can use below command: cat /proc/cpuinfo

3.What is “chmod” command? What do you understand by this line “r– -w- –x?

chmod command is used to change permission of a file or directory in UNIX. The line you see shows the permission for three different set of people : user, group and others. User is the currently logged in user, while group is for all other member which are part of certain group and others means anyone other than user and group member. Each group has three permissions rwx stands for read, write and execute and they are written as  user_group_others. So in above line, user has only read permission, group members has write permissions and other people has only execute permission. If it is a directory then you need execute permission to go inside that directory.

4.How do you find whether your system is 32 bit or 64 bit ?

Either by using “uname -a” command or by using “arch” command.

5.How do you set environment variable which will be accessible form sub shell?

By using export command, for example export count=1 will be available on all sub shell.
6.What different operating systems is vi available for?

Unix. That’s it.However, there are many, many clones of vi that are available for different operating systems.
7.What are some of the vi clones that are available?

STvi (STevie), elvis, lemmy, vile, vim, and nvi, xvi. elvis is available for: Amiga, DOS, OS/2, Unix, VMS, Atari, Psion3a Handheld.
8.How to quit without saving?

:q! will do it.

9.You have started up vi, but now want to be able to edit another file. How do you do this? :n <filename> will load that file into vi. You’ll need to save your current file.
10.How do I search for a control sequence? /<ctrl-v><ctrl-<seq>> <ctrl-v> will tell vi to take the next character literally, and not to take it as a command.

Program2 questions:

1.What is the difference between fopen() and open().

Ans: fopen() is the library function which internally calls the system callopen().

2.What is file pointer?

Ans: a pointer declared with data type FILE. It is used to store the base address of a file. 3.What is file descriptor.

Ans: It is the integer number assigned by the OS while opening the file with the system call open().

4.What are the modes used in open().

Ans: O_WRONLY, O_RDONLY, O_RDWR

5.What is FILE?

Ans: it is a pre-defined structure

Program3 Viva Questions:

1.what is the task of getwd(str)?

Ans: It reads the path of current working directory and stores that path as a string in str. 2.what is the task of alphasort().

Ans: it will sort the file names stored in the ―file‖. 3.why scandir() is used?

Ans: To scann the filedirectory names in a specific directory.

4.dirent stands for ________?

ans: directory entry.

5.what is the third argument in the scandir?

Ans: during scanning if we want to give some conditions then we write the name of the function where condition is defined.

Ex: select files if file size more than 100

Program4 Viva Questions:

1.What is pipe()?

Ans: it is a system call which will create a pipe with two file descrptors. fd[0] and fd[1]. One is for reading and other for writing.

2.What is the return value of pipe()?

Ans:It will return zero on success and -1 on failure.

3.What is the task of exec family members?

Ans: They will execute the command given in the area located to that process.

4.Is it mandatory to close the reading and while writing and close the writing end while reading.

Ans: it is a good habbit for synchronization between reading and writing.

5.What is the header file for exit().

Ans: stdlib.h

Program 5 Viva Questions:

1.How shared memory are accessed if we have two procesors trying to acquire the same region.

Ans:Synchronization should be done to protect the data corruption by simultaneous writes from two processes running on two different processors. Synchronization between two processors is best done with the help of spinlocks. When a process on one processor had locked the shared memory the other process running on the second processor shall be doing a busy spin until the first process released the lock. This is the funda of Spin locks 2.What is shmget()?

Ans: it is a system call to get memory allocation for a shared memory.

3.What is the return of shmget()?

Ans:A valid segment identifier, shmid, is returned on success, -1 on error.

4.what is ftok()?

Ans: it is the system call which convert a pathname and a project identifier to a System V IPC key.

5.what is the task of shmctl()?

Ans:shmctl() performs the control operation specified by cmd(2nd argument) on the shared memory segment whose identifier is given in shmid(1st argument).

Program 6 Viva Questions:

1.What are PTHREAD_COND_INITIALIZER, PTHREAD_COND_INITIALIZER, PTHREAD_MUTEX_INITIALIZER.

Ans:Pre-defined constants.

2.What is pthread_create().

Ans: to create a thread to run its own function.

3.What is pthread_join()?

Ans: a system call to make the parent process wait till the death of the child process. 4.What is producer consumer problem.

Ans:Suppose a producer produces 50 units per day but the consumer is having capacity to consume 100 units per day or vice-versa.Then it is called the producer consumer problem. 5.what is pthread_t?
Ans:It is the data type for the thread id.

Program 7 Viva Questions:

1.What is pthread_create().

Ans: to create a thread to run its own function.

2.What is pthread_join()?

Ans: a system call to make the parent process wait till the death of the child process. 3.what is pthread_t?

Ans:It is the data type for the thread id.

4.Why thread is used?

Ans: thread is used to exeute functions on it independently.

5.what is the command to compile thread program?

Ans: gcc filename.c -lpthread

Program 8 Viva Questions:

1.why it shows different output in different computer?

Ans: Sharing of CPU time among the threads depends upon the CPU scheduling.

2.What is pthread_join()?

Ans: a system call to make the parent process wait till the death of the child process. 3.what is pthread_t?

Ans:It is the data type for the thread id.

4.Why thread is used?

Ans: thread is used to exeute functions on it independently.

5. what is the command to compile thread program?

Ans: gcc filename.c –lpthread

1 comment:

My Feelings for death

 Kyu hoti hai kisi ki death, I don't know but why. M aaj tak nhi samjh pae ki ensan ki death kyu hoti hai. Kisi se bhi pucho to ye jawab...