MASTERS OF COMPUTER APPLICATON Q&A (FIRST YEAR)

 UNIX QUESTION AND ANSWER

Here's a breakdown of the UNIX and Shell Programming question paper, along with some potential answers:

Section A (MCQs/Fill in the blanks/Very short answer questions)

·  (a) A shell variable cannot start with a number or a special symbol other than an underscore.

·  (b) The first line of a shell script starts with a hash (#).

·  (c) The shell metacharacters $# and $* represent the number of arguments passed to the script and the list of all arguments, respectively.

·  (d) Two ways to identify if a file is ordinary or a directory are:

o    Using the ls -l command to see the file type (e.g., - for regular file, d for directory).

o    Using the file command to get detailed information about the file type.

·  (e) UNIX is written in C.

·  (f) The three modes of operation in vi are command mode, insert mode, and visual mode. Other editors available under UNIX include emacs, nano, and pico.

·  (g) To list all filenames starting with 'a', 'b', or 'k', you can use the command ls [abk]*.

·  (h) . represents the current directory, and .. represents the parent directory.

·  (i) To remove all empty directories in the path dir1/dir2/dir3/dir4, you can use the command rm -r dir1/dir2/dir3/dir4.

·  (j) To make a variable unchangeable in a shell script, use the readonly command. For example, readonly myvar.

Section B (Short Answer Questions)

·  (a) Explain UNIX file system.

·  (b) How to view current permissions of a file or directory:

o    ls -l to see permissions in human-readable format.

o    chmod 777: Sets all permissions (read, write, execute) for owner, group, and others.

o    chmod 755: Sets read, write, and execute permissions for owner, read and execute for group and others.

o    chmod +x: Adds execute permission for all users.

·  (c) The UNIX system variables mentioned signify:

o    HOME: Home directory of the user.

o    PS1: Primary prompt string.

o    PATH: Search path for commands.

o    TERM: Terminal type.

o    MAILCHECK: Interval to check for mail.

·  (d) The output of the shell script will be: set Only God is in a position to look down upon someone. echo $0 $10 $11 $

 

Here's a breakdown of the UNIX and Shell Programming question paper, along with some potential answers:

Section A (MCQs/Fill in the blanks/Very short answer questions)

·  (a) Which command is used to display and create the file?

o    Answer: (ii) vi

·  (b) What are the 3 modes of operation of vi?

o    Answer: Command mode, insert mode, and visual mode.

·  (c) Which command is used with the filename 'note' to remove the executable permission from user and assign the read permission to the group and others?

o    Answer: (i) chmod u-x,go+r note

·  (d) What do the terms UID, PID, and PPID stand for? For a particular process which is currently executing, how can you obtain these values?

o    Answer: UID = User ID, PID = Process ID, PPID = Parent Process ID. You can use the ps command to get these values.

·  (e) Which of the following is not a filter?

o    Answer: (ii) cal

Section B (Short Answer Questions)

·  (a) Explain UNIX file system.

·  (b) How to view current permissions of a file or directory:

o    ls -l to see permissions in human-readable format.

o    chmod 777: Sets all permissions (read, write, execute) for owner, group, and others.

o    chmod 755: Sets read, write, and execute permissions for owner, read and execute for group and others.

o    chmod +x: Adds execute permission for all users.

·  (c) The UNIX system variables mentioned signify:

o    HOME: Home directory of the user.

o    PS1: Primary prompt string.

o    PATH: Search path for commands.

o    TERM: Terminal type.

o    MAILCHECK: Interval to check for mail.

·  (d) The output of the shell script will be: set Only God is in a position to look down upon someone. echo $0 $10 $11 $

Section C (Long Answer Questions)

·  (a) Explain UNIX architecture and types of shells.

·  (b) Define shell scripts, their advantages, disadvantages, and types.

·  (c) Differentiate between System Call and Library Call.

·  (d) Write a shell script to calculate the area of a rectangle and triangle.

SECTION A

1. (a) Which command is used to extract specific columns from a file? Answer: cut

2. (b) Describe the stages that the client and server go through to establish a connection and also explain the following system calls: Answer:

·  Socket: Creates a socket descriptor to represent the endpoint for communication.

·  Bind: Assigns an IP address and port number to the socket descriptor.

·  Listen: Causes the socket to listen for incoming connections.

·  Accept: Accepts a connection request from a client.

·  Connect: Initiates a connection to a server.

3. (c) Define independent and cooperative process in UNIX? Answer:

·  Independent Process: A process that runs independently of other processes. It has its own memory space and resources.

·  Cooperative Process: A process that shares resources and communicates with other processes. It can be interrupted by the operating system to allow other processes to run.

4. (d) While executing the shell script either the LOGNAME or the UID is supplied at the command prompt. Write the shell script to find how many terminals has this user logged in. Answer:

#!/bin/bash

 

if [ "$1" = "" ]; then

    echo "Please provide LOGNAME or UID as argument"

    exit 1

fi

 

if [ "$1" -gt 0 ]; then

    who | grep "$1" | wc -l

else

    who | grep "$1" | wc -l

fi

5. (e) What do you mean by Daemon? How will you kill a Daemon? Answer:

·  Daemon: A background process that runs continuously, typically providing a service.

·  Killing a Daemon: Use the kill command with the process ID (PID) of the daemon. You can find the PID using the ps command.

 

6. (f) What would be the output of the following statements?

set who am i

echo $

Answer:

who am i

7. (g) For the command line arguments dog parrot cuckoo write the shell script which prints each argument in a separate line. Answer:

#!/bin/bash

 

for argument in "$@"; do

    echo "$argument"

done




        OPERATING SYSTEM QUESTION AND ANSWER

Operating system

SECTION B

1. Attempt any TWO of the following questions:

a. Explain critical section problem. Write down requirements for solution to critical section problem:

·  Critical Section Problem: A situation where multiple processes access a shared resource simultaneously, leading to unpredictable results.

·  Requirements for Solution:

o    Mutual Exclusion: Only one process can access the critical section at a time.

o    Progress: If no process is in the critical section, a process that wants to enter should be allowed to do so.

o    Bounded Waiting: There should be a limit on the number of times a process can be prevented from entering the critical section.

b. Explain in detail the implementation of Paging. Differentiate between internal and external fragmentation:

·  Paging: A memory management technique that divides physical memory into fixed-sized blocks called frames and logical memory into fixed-sized blocks called pages.

·  Internal Fragmentation: When a process is allocated a frame, there may be some unused space within that frame.

·  External Fragmentation: When there is enough free memory to allocate a process, but it is not contiguous, leading to wasted memory.

c. Differentiate between long, medium, and short-term process scheduling:

·  Long-Term Scheduling (Job Scheduling): Determines which processes are admitted into the system.

·  Medium-Term Scheduling (Swapping): Decides which processes to swap out of memory to make room for other processes.

·  Short-Term Scheduling (CPU Scheduling): Selects the next process to be executed by the CPU.

d. List names of five operating systems (OS). Discuss any two OS in detail with examples:

·  Windows: A popular operating system for personal computers.

·  Linux: An open-source operating system known for its flexibility and security.

·  macOS: An operating system developed by Apple for its Macintosh computers.

·  Android: A mobile operating system based on Linux.

·  iOS: A mobile operating system developed by Apple for its iPhones and iPads.

2. Attempt any ONE of the following questions:

a. What is the Banker's algorithm? Consider the following scenario of a system:

·  Banker's Algorithm: A resource allocation algorithm that prevents deadlocks by ensuring that processes request and release resources in a safe manner.

b. How can a critical section problem be related to a real-life scenario? Illustrate with an example:

·  Real-life scenario: Two people trying to use the same restroom at the same time.

·  Critical section problem: Both people trying to access the restroom at the same time, leading to a conflict.

3. Attempt any ONE of the following questions:

a. What are the necessary conditions for having deadlock in the system? Explain in detail:

·  Mutual Exclusion: Only one process can use a resource at a time.

·  Hold and Wait: A process holds a resource and waits for another resource.

·  No Preemption: A resource cannot be forcibly taken away from a process.

·  Circular Wait: A circular chain of processes exists, where each process is waiting for a resource held by the next process in the chain.

b. Explain memory management. Why paging is used?

·  Memory Management: The process of allocating and deallocating memory to processes.

·  Paging is used to:

o    Overcome the limitations of contiguous memory allocation.

o    Improve memory utilization.

o    Simplify memory management.

SECTION C

4. Attempt any ONE of the following questions:

a. Write short notes on:

·  Disk Structure: The organization of data on a disk, including tracks, sectors, and cylinders.

·  Disk Reliability: The ability of a disk to store data reliably over time, despite physical failures.

b. How does the operating system function as a resource manager?

·  CPU Scheduling: Allocating CPU time to processes.

·  Memory Management: Allocating memory to processes.

·  I/O Device Management: Managing I/O devices and their access.

·  File System Management: Organizing and managing files on storage devices.

5. Attempt any ONE of the following questions:

a. What is a semaphore? Write down different types of semaphore:

·  Semaphore: A synchronization mechanism used to control access to shared resources.

·  Types of Semaphore:

o    Binary Semaphore: Can have a value of 0 or 1.

o    Counting Semaphore: Can have a non-negative integer value.







COMPUTER ORGANIZATION AND ARCHITECTURE

 

1. (c) Write an assembly code statement to evaluate the arithmetic statement:

X = (A + B)'(C + D)

Using a general register computer with 3 address instruction:

ADD R1, A, B  // R1 = A + B

NOT R1        // R1 = (A + B)'

ADD R2, C, D  // R2 = C + D

AND X, R1, R2 // X = (A + B)'(C + D)

 

Using an accumulator (AC) type computer with one address instruction:

LOAD A         // Load A into accumulator

ADD B          // Add B to accumulator

NOT A          // Negate the accumulator

LOAD C         // Load C into accumulator

ADD D          // Add D to accumulator

AND A          // AND the accumulator with the previous result

 

Using a stack organized computer with 0 address instruction:

PUSH A

PUSH B

ADD

NOT

PUSH C

PUSH D

ADD

AND

 

1. (d) Explain SIMD interconnection network in detail.

A Single Instruction, Multiple Data (SIMD) interconnection network is a type of parallel processing architecture where multiple processors execute the same instruction on different data elements simultaneously. It is commonly used in vector and array processors.

There are various types of SIMD interconnection networks, including:

·  Linear Array: Processors are connected in a linear chain.

·  Ring: Processors are connected in a circular fashion.

·  Mesh: Processors are arranged in a two-dimensional grid.

·  Hypercube: Processors are connected in a multidimensional hypercube.

 

 

SECTION C

2. (a) Discuss the architecture of 8085 microprocessor in detail.

The 8085 microprocessor is an 8-bit microprocessor that has a 16-bit address bus and an 8-bit data bus. It has various registers, including the accumulator, the program counter, the stack pointer, and general-purpose registers. The 8085 also has an instruction set that includes instructions for arithmetic, logical, and control operations.

 

 

2. (b) What is Virtual Memory? An address space is specified by 24 bits and corresponding memory space by 16 bits.

·  How many words are there in the address space? 2^24 = 16,777,216 words

·  How many words are there in the memory space? 2^16 = 65,536 words

·  If a page consists of 4K words, how many pages and blocks are there in the system?Number of pages = 16,777,216 / 4096 = 4096 pages Number of blocks = 65,536 / 4096 = 16 blocks

 

3. (a) Find X[K] if x(n) = {2, -5, j, -1} using FFT.

You can use the Fast Fourier Transform (FFT) algorithm to calculate the Discrete Fourier Transform (DFT) of the given sequence.

 

3. (b) What is a controlled inverter, explain?

A controlled inverter is a type of inverter that can be turned on or off by an external control signal. It is often used in digital circuits to implement logic gates and other functions.

 

 

SECTION C

5. (a) What is Direct Memory Access (DMA)? Explain its working with proper diagram.

Direct Memory Access (DMA) is a technique that allows certain hardware subsystems to access main system memory independently of the CPU. This offloads the CPU from the task of transferring data between memory and I/O devices, improving overall system performance.

Diagram:

Working:

1.     DMA Request: The I/O device sends a DMA request to the DMA controller.

2.     DMA Controller Acquisition: The DMA controller requests bus access from the CPU.

3.     Bus Acquisition: The CPU relinquishes control of the bus to the DMA controller.

4.     Data Transfer: The DMA controller transfers data directly between the I/O device and memory, without involving the CPU.

5.     DMA Completion: Once the data transfer is complete, the DMA controller sends an interrupt to the CPU to signal completion.

 

 

5. (b) Find MAL, if the collision vector is given as 11010100

MAL (Minimum Address Length) is the minimum number of bits required to represent all the addresses in a memory system. In this case, the collision vector indicates that there are 8 memory modules. To address each module uniquely, we need at least 3 bits (2^3 = 8). Therefore, the MAL is 3.

 

 

6. (a) What is pipelining? Consider the execution of a program of 25000 instructions in a linear pipeline processor with a clock rate of 50 MHz. Assume that the instruction pipeline has 5 stages and that one instruction is issued per clock cycle. Calculate:

·  Speedup Factor

·  Efficiency

·  Throughput

Pipelining is a technique used in computer architecture to improve instruction throughput by overlapping the execution of multiple instructions.

·  Speedup Factor: Speedup Factor = (Ideal execution time without pipelining) / (Actual execution time with pipelining) Ideal execution time = 25000 instructions * 1 clock cycle/instruction = 25000 clock cycles Actual execution time = (Initial pipeline latency + Number of instructions) / Clock rate Initial pipeline latency = 5 stages * 1 clock cycle/stage = 5 clock cycles Actual execution time = (5 + 25000) / 50 MHz = 500.1 microseconds Speedup Factor = 25000 / 500.1 = 49.99

·  Efficiency: Efficiency = (Instruction execution rate) / (Maximum possible instruction execution rate) Instruction execution rate = 25000 instructions / 500.1 microseconds = 50,000 instructions/second Maximum possible instruction execution rate = Clock rate = 50 MHz = 50,000,000 instructions/second Efficiency = 50,000 / 50,000,000 = 0.001 or 0.1%

·  Throughput: Throughput = Number of instructions executed per unit time Throughput = 50,000 instructions/second

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

6.     (b) Draw and explain the working of serial adder and subtractor.

A serial adder adds two binary numbers bit by bit, starting from the least significant bit (LSB). A serial subtractor subtracts two binary numbers bit by bit, starting from the LSB. Both use a full adder circuit, which takes three inputs (two bits to be added and a carry-in) and produces two outputs (sum and carry-out).

 

 

7. (a) Write short notes on:

·  Vector Processing: Vector processing is a type of parallel processing where a single instruction operates on multiple data elements simultaneously.

·  SIMD Array Processor: A Single Instruction, Multiple Data (SIMD) array processor is a type of parallel computer architecture where multiple processors execute the same instruction on different data elements simultaneously.

7. (b) What is cache coherence, and why is it important in shared memory multi-processor systems? How can the problem be resolved?

Cache coherence is the consistency of data across multiple caches in a shared memory multi-processor system. It is important to maintain cache coherence to ensure that all processors have access to the most up-to-date data.

The problem of cache coherence arises when different processors have different copies of the same data in their caches, and one processor modifies the data without updating the other caches. This can lead to inconsistencies and

 

 

Here are the answers to the questions in the image:

SECTION A

1. Attempt ALL parts of the following questions:

a) Define Register in brief.

A register is a high-speed storage location within a computer's CPU that holds data temporarily. It is used to store instructions, data, addresses, or intermediate results during program execution.

 

 

b) Explain Half Adder in short.

A half adder is a digital circuit that adds two single-bit binary numbers. It has two inputs (A and B) and two outputs (Sum and Carry). The Sum output represents the sum of the two input bits, and the Carry output represents the carry-over bit.

 

 

c) Discuss RTL.

RTL (Register Transfer Language) is a hardware description language used to describe the behavior of digital circuits at the register transfer level. It allows for the specification of how data is transferred between registers and how operations are performed on that data.

 

d) What do you mean by Instruction format?

An instruction format defines the structure of an instruction in a computer's instruction set architecture. It specifies the different fields within an instruction, such as the opcode (operation code), operands, and addressing mode.

 

e) What type of operations can be performed in a stack? Explain with an example.

A stack is a data structure that follows the Last-In-First-Out (LIFO) principle. Common operations performed on a stack include:

·  Push: Adding an element to the top of the stack.

·  Pop: Removing the top element from the stack.

Example: Consider a stack of plates. When you add a plate, you place it on the top of the stack. When you remove a plate, you take it from the top.

 

f) Discuss any three types of memory used in a computer system.

Three common types of memory used in a computer system are:

·  RAM (Random Access Memory): Volatile memory used to store data and instructions currently being used by the CPU.

·  ROM (Read-Only Memory): Non-volatile memory used to store permanent instructions and data, such as the BIOS.

·  Cache Memory: High-speed memory that stores frequently accessed data to improve system performance.

·   

g) Enlist five Input/Output operations in a computer system.

Five common input/output operations are:

·  Keyboard input

·  Mouse input

·  Monitor output

·  Printer output

·  Disk drive input/output

h) Elaborate interrupt cycle.

An interrupt cycle is a sequence of events that occurs when a device interrupts the CPU to request service. The interrupt cycle typically involves the following steps:

1.     Interrupt request: The device sends an interrupt signal to the CPU.

2.     Interrupt acknowledgment: The CPU acknowledges the interrupt and saves the current program counter value.

3.     Interrupt service routine (ISR): The CPU jumps to the ISR associated with the interrupting device.

4.     ISR execution: The ISR handles the interrupt and performs the necessary actions.

5.     Return from interrupt: The ISR returns control to the interrupted program.

6.      

i) Discuss the use of Associative Memory?

Associative memory is a type of memory that allows data to be accessed based on its content rather than its address. It is used in applications such as cache memory, translation lookaside buffers (TLBs), and content-addressable memory (CAM).

 

j) Enlist six types of Addressing Modes.

Six common addressing modes are:

·  Immediate addressing: The operand is directly included in the instruction.

·  Direct addressing: The operand's address is directly specified in the instruction.

·  Indirect addressing: The address of the operand is stored in a memory location, and the instruction specifies the address of this memory location.

·  Register addressing: The operand is stored in a register.

·  Register indirect addressing: The address of the operand is stored in a register.

Index addressing: The address of the operand is calculated by adding a base address to an index value.

0/Post a Comment/Comments