0% found this document useful (0 votes)
12 views

4th-sem-BA-Unix-Scheme

The document outlines the syllabus and examination structure for the Fourth Semester B.A.(CS) Degree Examination in Computer Science, focusing on the UNIX Operating System. It includes sections with questions on operating system concepts, commands, process management, and shell scripting. The examination consists of multiple sections requiring answers to various questions, ranging from definitions to programming tasks.

Uploaded by

Sahana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

4th-sem-BA-Unix-Scheme

The document outlines the syllabus and examination structure for the Fourth Semester B.A.(CS) Degree Examination in Computer Science, focusing on the UNIX Operating System. It includes sections with questions on operating system concepts, commands, process management, and shell scripting. The examination consists of multiple sections requiring answers to various questions, ranging from definitions to programming tasks.

Uploaded by

Sahana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Q.P.

Code - 31453

Fourth Semester B.A.(CS) Degree Examination,

September/October 2024

(CBCS Scheme)

Computer Science

Paper BSCST 4.1 – UNIX OPERATING SYSTEM

SCHEME

Time – 3 Hours] [Max. Marks : 90

Instructions to Candidates : Answer all the Sections

SECTION A

I. Answer any TEN questions : (10 x 1 =10)


1. Define OS.
An Operating System (OS) is system software that manages hardware resources,
facilitates user interaction, and acts as an interface between users and the computer.
2. Mention any two types of OS.
 Multiuser Operating System
 Real-Time Operating System (RTOS)
3. Define a process.
A process is an instance of a program in execution, consisting of program code, data,
and system resources like memory and CPU time.
4. What is a scheduler?
A scheduler is a system program that determines which processes are given access to
the CPU based on their priority and time requirements.
5. Define a Kernel.
The kernel is the core component of an operating system responsible for managing
system resources, such as memory, processes, and devices.
6. Write the different types of shells.
 Bourne Shell (sh)
 Bash (Bourne Again Shell)
 C Shell (csh)
 Korn Shell (ksh)
 Z Shell (zsh)
7. What is the purpose of the finger command?
The finger command displays information about users logged into the system,
including their login name, home directory, and login time.
8. Why do we use the who command?
The who command is used to show the list of users currently logged into the system,
along with their terminal and login time.
9. What is the use of the ls command?
The ls command lists the contents of a directory, including files and subdirectories.
Q.P. Code - 31453

10. Define a loop.


A loop is a control structure in programming that repeats a block of code while a
condition is true or for a specified number of iterations.
11. Mention any two relational operators used in shell programming.
 -eq: Equal to
 -lt: Less than
12. What do you mean by command line arguments?
Command line arguments are parameters passed to a script or program when executed
from the terminal. They allow users to input data into the program during execution.

SECTION B
II. Answer any FIVE questions : (5 x 3 = 15)

13. Explain the components of OS.


The main components of an operating system include:
 Kernel: The core part that manages hardware resources like CPU, memory, and
devices.
 Process Management: Handles the creation, scheduling, and termination of
processes.
 Memory Management: Manages the allocation and deallocation of memory for
processes.
 File System: Organizes and manages files, directories, and access permissions.
 Device Management: Manages communication between the OS and hardware
devices.
 Security and Access Control: Protects data and resources from unauthorized access.

14. Explain PCB.


PCB stands for Process Control Block, a data structure in the operating system that
stores information about a process. Key information in the PCB includes:
 Process ID (PID): A unique identifier for the process.
 Process State: The current state (e.g., running, waiting, terminated).
 Program Counter: The address of the next instruction to be executed.
 CPU Registers: The current values in the CPU registers for the process.
 Memory Management Information: Information about the memory allocated to the
process.

15. Explain the features of Kernel.


The kernel is the heart of the operating system and has the following features:
 Resource Management: Manages CPU, memory, and I/O resources.
 Process Management: Schedules processes, manages multitasking, and handles
process synchronization.
 Security and Protection: Controls access to resources, ensuring only authorized
programs and users can interact with hardware.
 Memory Management: Allocates and deallocates memory to processes efficiently.
 Device Management: Handles communication with hardware devices through device
drivers.
16. What are the different types of file permissions in UNIX? Explain.
Unix file permissions are divided into three types:
 Read (r): Allows reading the contents of a file.
Q.P. Code - 31453

 Write (w): Allows modifying the contents of a file.


 Execute (x): Allows running the file as a program or script. These permissions are
assigned to three categories of users:
 Owner: The creator of the file.
 Group: Users who belong to the same group as the file owner.
 Others: All other users who do not belong to the owner's group. Permissions are
usually represented as a three-digit code, like 755, where each digit represents a set of
permissions for owner, group, and others.

17. Why do we use passwd and pwd command?


 passwd: This command is used to change a user's password. It prompts the user to
enter a new password and updates it securely.
 pwd: This command prints the current working directory, allowing the user to see the
absolute path of their location in the filesystem.

18. Write a shell program to check whether a given year is a leap year or not.
echo "Enter a year:"
read year
if [ $((year % 4)) -eq 0 ] && [ $((year % 100)) -ne 0 ] || [ $((year % 400)) -eq 0 ];
then
echo "$year is a leap year."
else
echo "$year is not a leap year."
Fi

19. Explain break and continue statements.


 break: The break statement is used to exit a loop prematurely, skipping all remaining
iterations. Example:
bash
Copy code
for i in {1..5}; do
if [ $i -eq 3 ]; then
break
fi
echo $i
done(This will print 1 and 2, then stop when it encounters 3).
 continue: The continue statement skips the current iteration and continues with the
next one. Example:
bash
Copy code
for i in {1..5}; do
if [ $i -eq 3 ]; then
continue
fi
echo $i
done(This will print 1, 2, 4, and 5, skipping 3).
Q.P. Code - 31453

SECTION C

III. Answer any SIX questions : (6x5=30)

20. Explain the process state with a neat diagram.


A process in an operating system passes through different states during its execution.
The primary process states are:
 New: The process is being created.
 Ready: The process is waiting to be assigned to the CPU.
 Running: The process is currently being executed by the CPU.
 Waiting (Blocked): The process is waiting for some event to occur (e.g., I/O
completion).
 Terminated: The process has finished execution.
 Suspended: The process is temporarily paused and moved to disk to free up memory.

21. Explain different services provided by an OS.


The operating system provides several important services, including:
 Process Management: Creation, scheduling, and termination of processes.
 Memory Management: Allocates and manages memory for processes.
 File Management: Provides an interface for creating, deleting, reading, and writing
files.
 I/O Device Management: Controls and manages input/output devices.
 Security and Protection: Ensures data and resource security through user
authentication and access control.
 Networking: Manages data exchange across networks, ensuring connectivity between
devices.

22. Explain preemptive and non-preemptive scheduling.


 Preemptive Scheduling: In preemptive scheduling, the operating system can forcibly
remove a process from the CPU if a higher-priority process arrives. This helps in
ensuring that critical tasks get CPU time promptly. Example: Round Robin
scheduling.
 Non-preemptive Scheduling: In non-preemptive scheduling, once a process starts
executing, it runs until it completes or voluntarily gives up the CPU (e.g., waiting for
I/O). No other process can interrupt it. Example: First-Come-First-Served (FCFS)
scheduling.

23. Explain any five file-related commands.


 cat: Displays the contents of a file.
 cp: Copies a file from one location to another.
 mv: Moves or renames a file.
 rm: Deletes a file.
 chmod: Changes the file permissions (read, write, execute) for the owner, group, and
others.
Q.P. Code - 31453

24. With an example, explain foreground and background processes.


 Foreground Process: A process that runs and takes control of the terminal until it
completes. The user cannot execute other commands until the process finishes.
Example:
nano file.txt
In this example, the nano editor opens in the foreground, blocking the terminal until it
is closed.
 Background Process: A process that runs in the background, allowing the user to
continue using the terminal while it executes. Example:
sleep 60 &
This command delays execution for 60 seconds in the background, freeing the
terminal for other commands.

25. With an example, explain grep and egrep commands.


 grep: The grep command searches for patterns in files and outputs lines that match
the pattern. Example:
grep "error" logfile.txt
This command searches for the word "error" in logfile.txt and displays matching lines.
 egrep: The egrep command (Extended grep) allows the use of extended regular
expressions. Example:
egrep "(error|warning)" logfile.txt
This searches for lines containing either "error" or "warning" in logfile.txt.

26. Explain logical operators in UNIX with example.


Logical operators in Unix are used for decision making in shell scripts:
 AND (&&): Returns true if both conditions are true. Example:
if [ $a -gt 0 ] && [ $a -lt 10 ]; then
echo "a is between 0 and 10"
fi

 OR (||): Returns true if at least one condition is true. Example:


if [ $a -lt 0 ] || [ $a -gt 10 ]; then
echo "a is outside the range 0 to 10"
fi

 NOT (!): Reverses the result of the condition. Example:


if [ ! -d /mydir ]; then
echo "/mydir does not exist"
fi

27. Write a shell program to print a string in reverse order.


echo "Enter a string:"
read str
len=${#str}
for (( i=$len-1; i>=0; i-- )); do
echo -n "${str:$i:1}"
done
echo
This script reads a string, calculates its length, and then prints each character in
reverse order.
Q.P. Code - 31453

SECTION D

IV. Answer any FIVE questions : (5x7=35)

28. Explain Distributed and Client-Server Operating System.

 Distributed Operating System:


In a distributed operating system, multiple interconnected computers communicate
and cooperate to achieve a common goal. The resources (CPU, memory, storage) are
shared across several systems, appearing as a single unified system to users. The key
features include:
o Resource sharing across multiple systems.
o Improved performance through parallelism.
o Fault tolerance as the failure of one system does not halt the entire operation.
o Example: Google's distributed data centers.
 Client-Server Operating System:
A client-server operating system is based on a centralized architecture where the
server provides resources, data, and services to multiple client machines. The client
sends requests to the server, which processes the requests and returns responses. Key
characteristics include:
o Centralized control of resources and services.
o Scalability and management ease.
o Examples: Web servers, database servers.

29. Explain FCFS and Round Robin Scheduling Algorithm.


 First-Come-First-Served (FCFS):
In FCFS scheduling, the process that arrives first in the queue is served first. This is a
non-preemptive scheduling algorithm.
o Simple and easy to implement.
o Disadvantages: Causes the convoy effect, where short jobs have to wait for
longer jobs. Example:
Arrival Order: P1 (5ms), P2 (3ms), P3 (8ms)
Execution Order: P1 → P2 → P3
 Round Robin (RR):
Round Robin scheduling is a preemptive scheduling algorithm where each process is
given a fixed time slot (called a time quantum). After the quantum expires, the
process is moved to the back of the queue if it is not finished.
o Fair and suitable for time-sharing systems.
o Example:
Arrival Order: P1 (5ms), P2 (3ms), P3 (8ms), Time Quantum: 2ms
Execution Order: P1 (2ms) → P2 (2ms) → P3 (2ms) → P1 (remaining 3ms) → ...

30. With a neat diagram, explain UNIX architecture.


The architecture of UNIX consists of the following layers:
 Hardware: This is the lowest layer that interacts with the physical system
components (CPU, memory, and I/O devices).
 Kernel: The core of the operating system that manages hardware resources and
provides system services like process and memory management.
Q.P. Code - 31453

 Shell: An interface for users to interact with the kernel, allowing them to execute
commands.
 Utilities and Applications: Higher-level tools that provide additional functionalities,
such as text editors and file management commands.

31. (a) Write a shell script to print the multiplication table for a given number.
echo "Enter a number:"
read num
for i in {1..10}; do
echo "$num * $i = $((num * i))"
done
(b) Write a shell script to count lines, words, and characters in its input.

"Enter a file name:"


read file
if [ -f "$file" ]; then
lines=$(wc -l < "$file")
words=$(wc -w < "$file")
chars=$(wc -c < "$file")
echo "Lines: $lines, Words: $words, Characters: $chars"
else
echo "File not found."
fi
32. (a) With an example, explain head and tail commands.
 head: Displays the first few lines of a file. By default, it shows the first 10 lines.
Example:
head filename.txt
 tail: Displays the last few lines of a file. By default, it shows the last 10 lines.
Example:
tail filename.txt
(b) Explain communication commands.
 write: Sends a message to another user who is logged in.
 mail: Sends email to a specified user.
 wall: Sends a message to all users logged into the system.
33. (a) Explain conditional statements with an example.
Conditional statements are used to make decisions in shell scripts. They are typically
written with if, elif, else. Example:

if [ $num -gt 0 ]; then


echo "Number is positive"
elif [ $num -lt 0 ]; then
echo "Number is negative"
else
echo "Number is zero"
fi
(b) With a syntax, explain while and until loop.
 while loop: Executes as long as the condition is true. Syntax:
while [ condition ]; do
# commands
done
Q.P. Code - 31453

 until loop: Executes until the condition becomes true. Syntax:


until [ condition ]; do
# commands
done
34. Write a note on:
(a) Absolute pathname and relative pathname.
 Absolute Pathname: Refers to the complete path from the root directory (/) to the
target file or directory. Example: /home/user/docs/file.txt.
 Relative Pathname: Refers to the path relative to the current working directory.
Example: ./docs/file.txt (if you are in /home/user).

(b) Parent and child process.


 Parent Process: The process that creates another process. For example, a shell that
starts a command creates a child process.
 Child Process: The process created by a parent process. It inherits some attributes
from the parent but runs independently. Example: A user running a script from the
terminal starts a child process.

You might also like