Top 550+ Solved Operating System Architecture MCQ Questions Answer
Q. What is the use of fcntl function?
a. locking a file
b. reading the file descriptor flag
c. changing the file status flag
d. all the above
Q. Which function can be used instead of the dup2 to duplicate the file descriptor?
a. read()
b. open()
c. stat()
d. fcntl()
Q. dup2(1,0)
a. closes the stdout and copies the stdin descriptor to stdout
b. closes the stdin and copies the stdout descriptor to stdin
c. will produce compilation error
d. none of the above
Q. Given a code snippet below? #define PERMS (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)int main() { int fd1, fd2; umask(0);fd1 = open(“file1”, O_CREAT | O_RDWR, PERMS)umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);fd2 = open(“file2”, O_CREAT | O_RDWR, PERMS)return 0;}The newly created files file1 and file2 will have the permissions respectively
a. rw-rw-rw- r——–
b. r——– rw-rw-rw-
c. rw-rw-rw- rw——
d. none of the abov
Q. Below is the codeint main() { int fd1, fd2;struct stat buff1, buff2;fd1 = open(“1.txt”, O_RDWR); fd2 = open(“2.txt”, O_RDWR | O_APPEND);lseek(fd1, 10000, SEEK_SET);write(fd1, “abcdefghij”, 10);write(fd2, “abcdefghij”, 10); fstat(fd1, &buff1);fstat(fd2, &buff2);printf(“ %d %d”, buff1.st_size, buff2.st_size);return 0;}Before running the program, the file 1.txt and 2.txt size is 20 each. What is the output?
a. 30 30
b. 100020 20
c. 100030 30
d. 100010 30
Q. ode snippets str1=”45678\n” str2=”123\n”f1 = fopen(file1,RDWR,RWX) f2 = fopen(file1,RDWR,RWX) write(f1,str1,len_str1) write(f2,str2,len_str2)o/p:
a. 12378
b. 123(newline)8(new line)
c. 123(newline)78(ne wline)
d. 45678(newline)1 23(newline)
Q. Code snippet (file1 size is 2024)f1 = fopen (file1, RDWR, RWX)lseek(f1,1024,SEEK_SET) write(f1,buf,10)What is offset now.
a. 1024
b. 1034
c. 2034
d. 2054
Q. what is file system
a. seqenceof bytes
b. sequence of bits
c. sequence of kilo bytes
d. sequence of megabytes