Operating Systems Quiz

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

What does the function e.getpid() return?

  • The ID of the currently loaded program
  • The current process ID of the calling process (correct)
  • The ID of the last terminated process
  • The process ID of the parent process

Which command is used to copy a file named 'source.txt' to 'destination.txt'?

  • mv source.txt destination.txt
  • copy source.txt destination.txt
  • duplicate source.txt destination.txt
  • cp source.txt destination.txt (correct)

What mechanism allows a parent process to check how a child process terminated?

  • The terminate() function
  • The wait() function (correct)
  • The getppid() function
  • The exit() function

What option with the ls command lists all files including hidden ones?

<p>ls -a (B)</p>
Signup and view all the answers

Which command would you use to permanently delete a file named 'file.txt'?

<p>rm file.txt (D)</p>
Signup and view all the answers

What is the main function of the mkdir command?

<p>To create a new directory (D)</p>
Signup and view all the answers

Which of the following commands is used to view currently running processes?

<p>both B and C (C)</p>
Signup and view all the answers

Which of these options allows the output of a command to be saved into a file?

<p>Using the &gt; operator (B)</p>
Signup and view all the answers

What happens when the buffer is full in the producer-consumer problem?

<p>The producer waits until the consumer consumes an item. (D)</p>
Signup and view all the answers

Which function is used to signal the consumer after an item has been produced?

<p>pthread_cond_signal (D)</p>
Signup and view all the answers

What is the role of the mutex in the producer-consumer problem?

<p>To ensure that only one thread can manipulate the buffer at a time. (B)</p>
Signup and view all the answers

What will happen if the consumer tries to consume an item when the buffer is empty?

<p>The consumer will wait until an item is produced. (C)</p>
Signup and view all the answers

What is the primary purpose of condition variables in this implementation?

<p>To synchronize access between producer and consumer threads. (D)</p>
Signup and view all the answers

In the context of this code, what is a race condition?

<p>When multiple threads modify shared data simultaneously, leading to inconsistent results. (C)</p>
Signup and view all the answers

What is the purpose of the deletion flag in a file structure?

<p>To mark the file as deleted without removing it (B)</p>
Signup and view all the answers

Which allocation method requires that each file occupies a set of contiguous blocks?

<p>Contiguous Allocation (D)</p>
Signup and view all the answers

What does the 'blocks' array signify in the file allocation method?

<p>Status of each block (free or occupied) (A)</p>
Signup and view all the answers

What is indicated by a return value of 0 in the allocateContiguous function?

<p>There is insufficient contiguous block space (B)</p>
Signup and view all the answers

What does the allocateContiguous function primarily check before allocating blocks?

<p>If sufficient contiguous blocks are available (B)</p>
Signup and view all the answers

Which of the following statements is true about Linked Allocation?

<p>Each block contains a pointer to the next block. (A)</p>
Signup and view all the answers

What is a major advantage of Contiguous Allocation?

<p>It allows for very quick file access due to sequential storage. (C)</p>
Signup and view all the answers

In the context of file operations, what does 'Display File' functionality accomplish?

<p>It shows the content of a file if it exists and is not deleted. (B)</p>
Signup and view all the answers

What function is used to create a new thread in POSIX threads?

<p>pthread_create (D)</p>
Signup and view all the answers

What is the primary purpose of using mutexes in multithreading?

<p>To synchronize access to shared resources (A)</p>
Signup and view all the answers

Which of the following statements about pthread_join is true?

<p>It blocks the calling thread until the specified thread finishes. (D)</p>
Signup and view all the answers

In the provided mutex example, what happens when pthread_mutex_lock is called?

<p>It sets the mutex to a locked state for the calling thread. (D)</p>
Signup and view all the answers

What issue does the producer-consumer problem illustrate in multithreading?

<p>Thread starvation (B)</p>
Signup and view all the answers

What is the result of a race condition in a multithreaded program?

<p>Shared data is accessed simultaneously leading to inconsistent results. (C)</p>
Signup and view all the answers

Which function correctly locks a mutex before accessing a shared resource?

<p>pthread_mutex_lock (C)</p>
Signup and view all the answers

Where would you typically use thread joins in a multithreaded application?

<p>At the end of the main function to prevent premature termination (A)</p>
Signup and view all the answers

What is the purpose of the isSafe() function in the Banker's Algorithm?

<p>To check if the system is in a safe state or not. (C)</p>
Signup and view all the answers

In the context of the program, what does the need[][] array represent?

<p>Remaining resources needed by each process. (D)</p>
Signup and view all the answers

Why is the finish[] array used in the isSafe() function?

<p>To record which processes have completed execution. (D)</p>
Signup and view all the answers

What method is used to update the work[] vector in isSafe()?

<p>By adding the resources allocated to finished processes. (B)</p>
Signup and view all the answers

If the count variable in isSafe() reaches the value of P, what can be concluded?

<p>All processes can finish with available resources. (B)</p>
Signup and view all the answers

What condition would result in the isSafe() function returning false?

<p>When no process can obtain its needed resources. (A)</p>
Signup and view all the answers

In the context of the Resource Allocation Graph (RAG), what do the nodes represent?

<p>Both processes and resources in the system. (C)</p>
Signup and view all the answers

What is the primary function of the calculateNeed() function in the program?

<p>To compute the difference between maximum needs and allocations. (A)</p>
Signup and view all the answers

What is the primary purpose of the fork() function in the provided code?

<p>To create a new child process (B)</p>
Signup and view all the answers

What happens if the fork() function fails?

<p>An error message is printed and the program exits (D)</p>
Signup and view all the answers

In the child process, what exit status does it return before terminating?

<p>10 (A)</p>
Signup and view all the answers

Which function is used to wait for the child process to finish executing?

<p>wait() (D)</p>
Signup and view all the answers

What function is called to check if the child process exited normally?

<p>WIFEXITED() (C)</p>
Signup and view all the answers

What will happen if the exec() function is successful?

<p>The process is replaced by the new program with no return (C)</p>
Signup and view all the answers

What does the printf statement in the parent process output after the child exits normally?

<p>Child exited with status 10 (A)</p>
Signup and view all the answers

What is the purpose of getpid() in the child process?

<p>To get its own process ID (A)</p>
Signup and view all the answers

Which signal indicates that the child process was terminated abnormally?

<p>WIFSIGNALED (B)</p>
Signup and view all the answers

In the exec() example, which command is executed if exec() is successful?

<p>ls -l (D)</p>
Signup and view all the answers

Study Notes

Subject: Lab Assignment - Operating System

  • Student name: Suwarnika Srivastava
  • Registration number: 23BSA10092
  • Course code: CSE3003
  • Slot: A21 + A22 + A2
  • Assignment ID: 3

Question 1: Process Creation and Management

  • Objective: Understand process creation, termination, and management in the operating system.
  • Tasks: Write a C program to create a new process using fork().
    • Implement the parent-child process relationship.
    • Demonstrate process termination.
    • Use exec() to replace a process image.
    • Demonstrate the use of process IDs and status handling.

Question 2: Basic OS Commands

  • Objective: Learn and practice basic operating system commands.
  • Tasks:
    • File management (e.g., ls, cp, mv, rm, touch).
    • Process management (e.g., ps, kill, top).
    • Directory navigation (e.g., cd, pwd, mkdir).
    • I/O redirection and piping (e.g., |, >, >>).

Question 3: CPU Scheduling Algorithms

  • Objective: Simulate different CPU scheduling algorithms.
  • Tasks:
    • Write a program to simulate First-Come-First-Served (FCFS) scheduling.
    • Implement Shortest Job First (SJF) scheduling (with or without preemption).
    • Simulate Round Robin (RR) scheduling and calculate turnaround and waiting times.
    • Implement Priority Scheduling and test with different sets of priorities.

Question 4: Inter-Process Communication (IPC)

  • Objective: Implement communication between processes.
  • Tasks:
    • Write a program using pipes for IPC between parent and child processes.
    • Implement shared memory for communication between multiple processes.
    • Use message queues to exchange data between processes.
    • Demonstrate use of semaphores for synchronization.

Question 5: Thread Creation and Synchronization

  • Objective: Work with multithreading in an operating system.
  • Tasks:
    • Create multiple threads using POSIX threads (pthreads) in C.
    • Implement thread synchronization using mutexes or semaphores.
    • Write a program to demonstrate race conditions and resolve them using locks.
    • Simulate the producer-consumer problem using multithreading.

Question 6: Deadlock Detection and Prevention

  • Objective: Implement deadlock avoidance and detection techniques.
  • Tasks:
    • Write a program to simulate a system with multiple resources and processes.
    • Implement Banker's Algorithm for deadlock avoidance.
    • Demonstrate deadlock detection using a resource allocation graph.
    • Analyze a situation where deadlock occurs and suggest ways to resolve it.

Question 7: Memory Management Techniques

  • Objective: Implement and simulate different memory management techniques.
  • Tasks:
    • Simulate paging and segmentation using C or Java.
    • Implement page replacement algorithms (FIFO, LRU, Optimal).
    • Write a program to simulate allocation and deallocation of memory blocks using First Fit, Best Fit, and Worst Fit algorithms.

Question 8: File System Implementation

  • Objective: Understand file system operations and implement basic file management.
  • Tasks:
    • Write a program to simulate the creation, deletion, and manipulation of files in a directory.
    • Implement file allocation methods (Contiguous, Linked, Indexed).
    • Simulate disk scheduling algorithms (FCFS, SSTF, SCAN, C-SCAN).

Question 9: Virtual Memory Management

  • Objective: Work with virtual memory and page management.
  • Tasks:
    • Implement a simulation of virtual memory using paging.
    • Write a program to simulate the demand paging concept.
    • Simulate page replacement policies (FIFO, LRU).
    • Implement a program to track page faults during process execution.

Question 10: Disk Scheduling Algorithms

  • Objective: Understand and implement various disk scheduling algorithms.
  • Tasks:
    • Simulate First-Come-First-Served (FCFS) disk scheduling.
    • Implement Shortest Seek Time First (SSTF) disk scheduling.
    • Write a program to simulate SCAN, C-SCAN disk scheduling.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Operating Systems: Process Management
10 questions
Commandes et fonctions basiques Linux
23 questions
Betriebssystem Ressourcen und Management
45 questions
Linux Commands and Processes Quiz
29 questions
Use Quizgecko on...
Browser
Browser