0% found this document useful (0 votes)
9 views9 pages

PQnA 19 - 20

The document discusses memory management in operating systems, including job accommodation, device drivers, and the Banker's algorithm for deadlock avoidance. It also covers file management activities, the implications of file deletion policies, and protection problems related to file access mechanisms. Additionally, it outlines the steps taken during hardware interrupts and the importance of systems networking.

Uploaded by

Abdullah Opadeji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views9 pages

PQnA 19 - 20

The document discusses memory management in operating systems, including job accommodation, device drivers, and the Banker's algorithm for deadlock avoidance. It also covers file management activities, the implications of file deletion policies, and protection problems related to file access mechanisms. Additionally, it outlines the steps taken during hardware interrupts and the importance of systems networking.

Uploaded by

Abdullah Opadeji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

CSC 314 2019/2020 PQ

1.Given the memory configuration in FIG 2.9, answer the following questions. At this
point, Job 4 arrives requesting a block of 100K.
Operating System 20K
Job 1 (10K) 30K
50K
Job 2 (15K) 65K
75K
Job 3 (45K) 120K
200K

a.Can Job 4 be accommodated? Why or why not?

The memory configuration before and after compaction is as shown in the image

a)
Assuming relocation cannot take place, free space in one continuous chunk is maximum 80K , so
the process cannot fit as its requirement is 100K . However is relocation can take place, the
process can be accomodated as total available space is 80+10+20 =110.
b.If relocation is used, what are the contents of the relocation registers for Job 1, Job 2, Job
3, after compaction?
Contents of relocation registers -
For J1 , no relocation takes place, so content of reloc register is 0.
For J2 , it moves from 50K to 30K, so content of reloc register = 30K-50K = -20K = -20*1024=
-20480
For J3, it moves from 75K to 45K, so contents of reloc register = 45K-75K = -30K = -30 *
1024= -30720

c.What are the contents of the relocation register for Job 4 after it has been loaded into
memory?
J4 is loaded after compaction, so reloc register content for it is 0

d. Use best fit algorithm to indicate with memory blocks are allocated to each of the three
arriving jobs

Job Number Memory Requested Memory Block Memory Block Size

Job 1 690k Block 1 900k

Job 2 275k Block 2 910k

Job 3 760k Block 3 300k

● Job 1: allocated to Block 1 (690k fits within the 900k block)


● Job 2: allocated to Block 2 (275k fits within the 910k block)
● Job 3: allocated to Block 3 (760k fits within the 300k block)

2ai. What are device drivers?

Device drivers are programs that allow your computer to communicate with specific hardware or
devices. They act as a translator between the operating system and the device, allowing the
operating system to send instructions to the device and the device to send data back to the
operating system. Device drivers are an essential part of many different types of hardware,
including printers, scanners, and other peripheral devices.

ii State three advantages of placing functionality in a device controller, rather than in the
kernel. State three disadvantages

Three advantages of placing functionality in a device controller, rather than in the kernel, are:
1. Improved performance: Device controllers can be designed to run specific tasks in a more
efficient manner, which can help improve the overall performance of the system.
2. Better organization: By separating the different functions of a device into separate
controllers, it is easier to organize the code and maintain the system.
3. More flexibility: Device controllers can be swapped out and replaced with different ones,
allowing for more flexibility in terms of the hardware that can be used with the system.

Three disadvantages of placing functionality in a device controller, rather than in the kernel, are:
1. Increased complexity: Adding more layers to the system can make it more complex and
harder to understand and maintain.
2. Reduced security: Device controllers are typically run with higher privileges than other
parts of the system, which can make it easier for attackers to gain access to sensitive
information or perform other malicious actions.
3. Potential compatibility issues: Different device controllers may not be compatible with
each other, which can lead to compatibility issues and difficulty in getting different
hardware to work together.

2bi. Describe Banker's algorithm.


The Banker's algorithm is a method used in deadlock avoidance for resource allocation in a multi-task
operating system. It is named after Edsger Dijkstra, who developed the algorithm in the early 1970s.
The algorithm works by keeping track of the available resources and the maximum resources that each
task will need. When a task requests a resource, the algorithm checks whether granting the request will
result in a safe state, where all tasks can still be completed without deadlock. If the state is safe, the
request is granted. Otherwise, the request is denied until the system reaches a safe state.
The Banker's algorithm can help prevent deadlock situations by ensuring that resources are allocated in a
way that avoids conflicts and ensures that all tasks can complete. It is often used in real-time systems
where it is important to avoid deadlock situations and ensure that tasks are completed in a timely manner.

OR

The Banker's algorithm is a resource allocation and deadlock avoidance algorithm that is used in
operating systems to manage the allocation of resources, such as memory or processor time,
among multiple processes. The algorithm aims to prevent deadlocks by ensuring that the system
always has a safe state, where a safe state is defined as a state in which there exists a possible
allocation of resources to processes that will not result in a deadlock. The algorithm does this by
keeping track of the maximum resources a process may need in the future, and only granting a
process a resource if it can be done without putting the system in an unsafe state.
ii Give two (2) examples of a deadlock that could occur in the physical world Give two (2)
examples of a deadlock that could occur in the physical
world and explain how it could be resolved.
1. Two cars could be approaching an intersection from opposite directions and both drivers
try to enter the intersection at the same time, resulting in a deadlock where neither car can
proceed. This situation could be resolved by one of the drivers backing up and yielding to
the other car to pass through the intersection first.
2. Two people could be trying to use the same tool or piece of equipment at the same time,
resulting in a deadlock where neither person can use the tool until the other person
finishes. This situation could be resolved by one of the people agreeing to wait for the
other person to finish using the tool, or by finding another tool that can be used
simultaneously by both people.

2c. Suppose we have five processes, and three resources, A, B, and C. A has 2 instances, B
has 5 instances and C has 4 instances. Can the system execute the following processes
without deadlock occurring, where we have the following?

Maximum Allocation
Need

Process A B C A B C

P1 1 2 3 0 1 1

P2 2 2 0 0 1 0

P3 0 1 1 0 0 1

P4 3 5 3 1 2 1

P5 1 1 2 1 0 1

It is possible for the system to execute the processes without a deadlock occurring, given the
information provided. To determine this, we need to check if the system satisfies the necessary
conditions for a deadlock to occur.

One necessary condition for a deadlock to occur is that each process must be holding at least one
resource, and requesting another resource that is currently being held by another process. From
the information provided, this condition is not met, as no process is holding any resources.
Another necessary condition for a deadlock to occur is that there must be a set of processes such
that each process in the set is waiting for a resource held by another process in the set. From the
information provided, this condition is also not met, as no process is waiting for any resources.
Therefore, it is possible for the system to execute the processes without a deadlock occurring.

SECTION B

Answer one Question in this Section

3a i. Mention any three (3) factors that need to be considered in I/O device complexity from
the operating system and the user processes point of view.
1. The amount of data that needs to be transferred between the I/O device and the operating
system or user process.
2. The speed at which the data needs to be transferred.
3. The type of data transfer, such as block-oriented or character-oriented.
4. The level of reliability required for the data transfer, such as error checking and
correction mechanisms.
5. The level of security required for the data transfer, such as encryption and authentication.
6. The level of compatibility with other I/O devices and the operating system.
7. The level of support provided by the operating system for the I/O device.

ii. When designing the file structure for an operating system, what four (4) attributes must
you consider?
1. The type and size of files that will be stored in the file system.
2. The amount of storage space that will be available for the file system.
3. The performance requirements for accessing and modifying files in the file system.
4. The security requirements for protecting files in the file system.
5. The reliability requirements for ensuring the integrity of the file system.
6. The compatibility requirements for interfacing with other file systems and operating
systems.
7. The scalability requirements for allowing the file system to grow and adapt to changing
needs over time.

3bi. State any four (4) activities of the operating system in regard to file management.
1. Creating and deleting files and directories.
2. Allocating and deallocating storage space for files.
3. Enforcing access controls and permissions on files.
4. Providing mechanisms for reading from and writing to files.
5. Maintaining the integrity of the file system by performing regular consistency checks.
6. Backing up and restoring files in case of data loss or corruption.
7. Providing a user-friendly interface for managing and accessing files.
8. Supporting the creation and management of virtual files, such as virtual memory.

ii. Some systems automatically delete all user files when a user logs off or a job terminates,
unless the user explicitly requests that they be kept; other systems keep all files unless the
user explicitly deletes them. Discuss the relative merits of each approach.

There are pros and cons to both approaches. The advantage of automatically deleting user files
when a user logs off or a job terminates is that it can help to conserve storage space, especially if
multiple users are using the system and generating a large number of files. This approach can
also help to prevent data leaks, as it ensures that sensitive information is not left on the system
where it could potentially be accessed by unauthorized users.
On the other hand, the disadvantage of automatically deleting user files is that it can be
inconvenient for users who want to keep their files. This is especially true if the user is not aware
that their files will be deleted and they do not take the necessary steps to save them. In such
cases, the user may lose important data that they were not able to recover.

In contrast, the advantage of keeping all user files unless the user explicitly deletes them is that it
allows users to have greater control over their own data. This approach can be more convenient
for users, as it means that they do not have to worry about their files being automatically deleted.
Additionally, it allows users to access their files at a later time, even if they have logged off or
their job has terminated.

However, the disadvantage of this approach is that it can lead to a buildup of unused files, which
can waste storage space and potentially slow down the system. Additionally, it can increase the
risk of data leaks, as sensitive information may be left on the system if the user forgets to delete
it.

Ultimately, the best approach will depend on the specific needs and goals of the system in
question. For example, a system that is used by multiple users and has limited storage space may
be better off automatically deleting user files, while a system that is used by a single user and has
plenty of storage space may be better off keeping all user files unless the user explicitly deletes
them.

4ai. File access mechanism refers to the manner in which the records of a file may be
accessed. Discuss. In some systems, a subdirectory can be read and written by an
authorized user, just as ordinary files can be
1. Describe the protection problems that could arise.

The protection problems that could arise with a file access mechanism that allows a subdirectory
to be read and written by an authorized user are as follows:
1. Unauthorized access: If a subdirectory is accessible to an authorized user, it is also
possible for an unauthorized user to gain access to the subdirectory and potentially read
or modify its contents.
2. Data corruption: If multiple users are allowed to read and write to the same subdirectory,
there is a risk of data corruption if two users attempt to modify the same file at the same
time.
3. Loss of data integrity: If a user is able to modify the contents of a subdirectory, they may
accidentally or intentionally delete or modify important files, leading to loss of data
integrity.
4. Inefficient use of storage space: If a subdirectory is accessible to multiple users, it is
possible for multiple copies of the same file to be created, leading to inefficient use of
storage space.
To mitigate these problems, it is important to implement a robust file access mechanism that
allows only authorized users to access the subdirectory, and that controls access to the
subdirectory in a way that ensures data integrity and prevents unauthorized access.

2. Suggest a scheme for dealing with each of these protection problems.


To address the protection problems associated with a file access mechanism that allows a
subdirectory to be read and written by an authorized user, the following steps can be taken:
1. Implement user authentication: Only allow users who have been properly authenticated to
access the subdirectory. This can be done through the use of unique login credentials
(such as a username and password), and can be reinforced through the use of additional
authentication measures such as two-factor authentication.
2. Implement access control: Use an access control mechanism to ensure that only
authorized users have access to the subdirectory. This can be done through the use of
access control lists (ACLs), which specify the permissions that each user has to access
the subdirectory and its contents.
3. Implement version control: Use a version control system to track changes made to files
within the subdirectory. This will allow users to easily revert to previous versions of a file
if necessary, and will prevent data corruption or loss of data integrity.
4. Implement data backup: Regularly back up the contents of the subdirectory to prevent
loss of data due to accidental deletion or corruption. This can be done through the use of
automated backup systems, which can be configured to regularly copy the contents of the
subdirectory to a secure storage location.
5. Monitor access to the subdirectory: Regularly monitor access to the subdirectory to
identify and prevent unauthorized access. This can be done through the use of security
logs, which can track access attempts to the subdirectory and alert administrators if any
suspicious activity is detected.

ii. Interrupts are part of a hardware mechanism that sends a notification to the CPU when
it wants to gain access to a particular resource, e.g., when you move your mouse, access
hard drive etc. List four (4) steps taken when such an interrupt occurs.

When an interrupt occurs, the following steps are typically taken:


1. The CPU receives the interrupt signal and stops executing the current instruction.
2. The CPU saves the current state of its registers and memory, so that it can resume
execution of the interrupted program once the interrupt is handled.
3. The CPU determines the cause of the interrupt and identifies the appropriate interrupt
handler routine to handle the interrupt.
4. The CPU transfers control to the interrupt handler routine, which executes the necessary
actions to handle the interrupt. This may involve accessing the resource that caused the
interrupt, or performing some other action.
5. Once the interrupt handler routine has completed its tasks, the CPU restores the saved
state of its registers and memory, and resumes execution of the interrupted program.

b. State four (4) valid reasons why you think that systems networking is essential.
1. Improved communication and collaboration: Networking allows multiple computers and
devices to communicate and share information with each other, enabling users to
collaborate and work together more effectively.
2. Increased productivity: By allowing users to access and share information and resources,
networking can help increase the productivity of individuals and teams.
3. Better access to information and resources: Networking allows users to access a wider
range of information and resources, such as databases, files, and applications, from any
location.
4. Enhanced security: Networking can help improve security by enabling the use of security
measures such as firewalls and encryption, and by allowing administrators to monitor and
control access to network resources.

c. Compare Peer-to-Peer and Client/Server model using the underlisted factors to generate
a comparative table
Factors:
1. Ease of Setup; 2. Resources Sharing; 3. Network Management; 4. Multi-Access; 5.
Storage System

Factor Peer-to-Peer Client/Server

P2P networks are generally easy to set Client/server networks require


Ease of Setup up and require little to no technical more technical expertise to set
expertise. up and may be more complex.

In a client/server network,
Resource In a P2P network, resources are shared resources are shared through a
Sharing directly between devices on the network. central server that manages
access to those resources.

P2P networks are decentralized, which


In a client/server network, a
means that each device on the network is
central server is responsible for
Network responsible for managing its own access
managing access to resources,
Management to resources. This can make P2P
which can make network
networks more difficult to manage
management easier.
overall.

Client/server networks also


P2P networks allow multiple devices to
allow multiple devices to access
Multi-Access access and share resources
and share resources
simultaneously.
simultaneously.

In a P2P network, each device on the In a client/server network, files


network may have its own storage are typically stored on a central
Storage System
system, and files may be stored on any server, and access to those files
device on the network. is managed by the server.

Overall, the key differences between P2P and client/server networks are the way that resources
are shared and managed. P2P networks are decentralized and rely on individual devices to
manage access to resources, while client/server networks are centralized and rely on a central
server to manage access to resources.

You might also like