CSC2404 Assignment 1: Operating Systems Concepts and Implementation
VerifiedAdded on 2022/09/27
|9
|1901
|17
Homework Assignment
AI Summary
This assignment solution for CSC2404, focusing on operating systems, addresses four key questions. The first question explores the role of system calls, the necessity of kernel involvement, and the mechanisms for notifying the kernel of service requests, providing examples from Linux. The second question delves into cache design, purpose, management, and coherency, examining these concepts in single and multi-processor environments. The third question differentiates between concurrency and parallelism, explaining the advantages and disadvantages of kernel and user threads, and analyzes a code snippet involving threads and processes. Finally, the fourth question discusses the purpose of interrupts, their critical role in modern computers, and the differences between interrupts and traps, along with the purpose of timers in operating systems. The document provides comprehensive explanations and examples to illustrate the concepts.

1
csc2404 Assignment 1
csc2404 Assignment 1
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

2
Question 1
A “system call” is used by a process to request that the kernel perform a task on behalf of the
requesting process
Why is it necessary that the kernel perform tasks on behalf of processes? Why doesn’t the
process perform the tasks itself?
The operating system consists of two parts, kernel is one of them and kernel being
the core part of the operating system it has to work on task. It acts has an
intermediary between applications and the information that is being executed. The
kernel also ensures that there is little abstraction so that the various tasks can be
accomplished by the various applications involved. This is made an easy task by
the kernel through process intercommunication
The process does not perform the tasks by itself due to the following reasons.
The tasks cannot be executed by the process because they cannot act as
intermediaries between the various software and hardware devices
The process does not have the ability to communicate with each other in the first
place and so making it impossible for software applications to pass information to
the hardware devices
The details of the system call interface is hidden from the programmer as the operating
system supplies a library of standardized function calls4. Linux and macOS has over 300
such system functions.
– Explain how these functions actually notify the kernel that a service is being requested of
it, and
A system call is when a program asks for an administration from the part of an
operating system it is being worked on. This is done when there is need for the
working system to cooperate with a certain framework given. The Application
Program Interface works with the system call to give administrations to programs. It
acts as a link between the process used and the existing framework to allow client
programs to ask for administrations.
–explain the different methods used to:
identify the system call being requested, and
Question 1
A “system call” is used by a process to request that the kernel perform a task on behalf of the
requesting process
Why is it necessary that the kernel perform tasks on behalf of processes? Why doesn’t the
process perform the tasks itself?
The operating system consists of two parts, kernel is one of them and kernel being
the core part of the operating system it has to work on task. It acts has an
intermediary between applications and the information that is being executed. The
kernel also ensures that there is little abstraction so that the various tasks can be
accomplished by the various applications involved. This is made an easy task by
the kernel through process intercommunication
The process does not perform the tasks by itself due to the following reasons.
The tasks cannot be executed by the process because they cannot act as
intermediaries between the various software and hardware devices
The process does not have the ability to communicate with each other in the first
place and so making it impossible for software applications to pass information to
the hardware devices
The details of the system call interface is hidden from the programmer as the operating
system supplies a library of standardized function calls4. Linux and macOS has over 300
such system functions.
– Explain how these functions actually notify the kernel that a service is being requested of
it, and
A system call is when a program asks for an administration from the part of an
operating system it is being worked on. This is done when there is need for the
working system to cooperate with a certain framework given. The Application
Program Interface works with the system call to give administrations to programs. It
acts as a link between the process used and the existing framework to allow client
programs to ask for administrations.
–explain the different methods used to:
identify the system call being requested, and

3
Cat/usr/include/asm/unis td.h | less
Pass the data to the kernel that may be required by the system call.
A call gate is certain location used by an operating system in part of the memory to
a certain place known as the processor. When a processor gets the difference
between an address to a call it then diverts the specified area without bringing about
confusion
Which of the systems described here does Linux use?
The Linux operating system uses kernel thread
Using actual Linux system calls as examples, explain what sort of tasks an operating
system will perform on behalf of a process? (see the man pages intro(2), syscalls(2), and
Section 2).
The functions operating system performs on behalf of a process include;
• Linux Exec System Call - this system call is used in execution of a file residing in a
process that is active. A new file is executed when exec is called and the previous
executable file replaced. Generally, the exec system call is used to replace the old
program or file from the process with a new program or file. The exec() system call
is executed by the user data segment. The segment is then replaced with the data
file of the name provided during the calling of exec().
• Fork System Call - this system call creates new processes which becomes the child
process. The parent process is the process that creates a new process and calls a fork
as well. Both are concurrently executed although they reside on different memory
spaces.
• Stat System Call – this call checks the file status such as checking the time of
accessing the file. The file attributes are returned by the stat() system call (Fjeldstad
et al., 2012).
Question 2
Caches are an integral part of modern processor design. What is a Cache? What is its
purpose?
A cache is number of components that are often stored in an inaccessible place. It
is also a type of memory that can be used to boost the speed at which an
Cat/usr/include/asm/unis td.h | less
Pass the data to the kernel that may be required by the system call.
A call gate is certain location used by an operating system in part of the memory to
a certain place known as the processor. When a processor gets the difference
between an address to a call it then diverts the specified area without bringing about
confusion
Which of the systems described here does Linux use?
The Linux operating system uses kernel thread
Using actual Linux system calls as examples, explain what sort of tasks an operating
system will perform on behalf of a process? (see the man pages intro(2), syscalls(2), and
Section 2).
The functions operating system performs on behalf of a process include;
• Linux Exec System Call - this system call is used in execution of a file residing in a
process that is active. A new file is executed when exec is called and the previous
executable file replaced. Generally, the exec system call is used to replace the old
program or file from the process with a new program or file. The exec() system call
is executed by the user data segment. The segment is then replaced with the data
file of the name provided during the calling of exec().
• Fork System Call - this system call creates new processes which becomes the child
process. The parent process is the process that creates a new process and calls a fork
as well. Both are concurrently executed although they reside on different memory
spaces.
• Stat System Call – this call checks the file status such as checking the time of
accessing the file. The file attributes are returned by the stat() system call (Fjeldstad
et al., 2012).
Question 2
Caches are an integral part of modern processor design. What is a Cache? What is its
purpose?
A cache is number of components that are often stored in an inaccessible place. It
is also a type of memory that can be used to boost the speed at which an
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

4
information can be accessed in a computer procedure.
What is cache management. Why is it an important design problem?
The organization and storage of data to be used later is known as Cache
management and is often stored as software
Since it involves storing information any place in the computer making it easy for
access this makes it an important design problem
What is cache coherency?
It is the continuation of data that is shared and kept in various caches.
Discuss, with examples, how the problem of maintaining the coherency of cached data
manifest itself in the following pro cessing environments:
a) Single- processor systems
This type of process contributes to incoherency since a number of process are
executed all at once i.e. multiple task processed.
b) Multi- processor systems
In this kind of system each processor has its own cache. A part of process one may
exist in other
Many multi-core systems have different levels of cache on the chip,
one level is local to each processing core (L1 and L2 on Intel
systems), and another level is shared among all processing cores
(L3 on Intel systems). Why are caching systems designed this way.
They are designed in that way to allow cache coherence. When one core is
modified, all the other copies shared in the cache line are invalidated on the rest of
the cores. As a result, if the same line of cache is required later by a different core,
whatever may have been stored in its local line can no longer be good, instead, the
core has to go out to the main memory to acquire a usable replacement.
Question 3
a. Explain the difference between concurrency and parallelism.
Concurrency refers to more than one tasks seem to be executed at the same time
information can be accessed in a computer procedure.
What is cache management. Why is it an important design problem?
The organization and storage of data to be used later is known as Cache
management and is often stored as software
Since it involves storing information any place in the computer making it easy for
access this makes it an important design problem
What is cache coherency?
It is the continuation of data that is shared and kept in various caches.
Discuss, with examples, how the problem of maintaining the coherency of cached data
manifest itself in the following pro cessing environments:
a) Single- processor systems
This type of process contributes to incoherency since a number of process are
executed all at once i.e. multiple task processed.
b) Multi- processor systems
In this kind of system each processor has its own cache. A part of process one may
exist in other
Many multi-core systems have different levels of cache on the chip,
one level is local to each processing core (L1 and L2 on Intel
systems), and another level is shared among all processing cores
(L3 on Intel systems). Why are caching systems designed this way.
They are designed in that way to allow cache coherence. When one core is
modified, all the other copies shared in the cache line are invalidated on the rest of
the cores. As a result, if the same line of cache is required later by a different core,
whatever may have been stored in its local line can no longer be good, instead, the
core has to go out to the main memory to acquire a usable replacement.
Question 3
a. Explain the difference between concurrency and parallelism.
Concurrency refers to more than one tasks seem to be executed at the same time
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

5
whereas parallelism refers to when tasks are processed simultaneously
b. There are two ways to support threads: kernel threads or user threads—
i. Most operating systems support both ways. Explain the advantages and
disadvantages of kernel threads and user threads,
Advantages of;
Kernel threads
• Efficient for applications that are often closed
• The application that has more threads is given more time
User threads
• Used by Operating System that does not take threads
• They are fast enough
• They are efficient since they are simpler
Disadvantages of;
Kernel threads
• They are not fast and are non -efficient
• They are complex
User thread
• The kernel and the operating system don’t work together
• They require calls so as not to block them
ii. Linux and Windows maps one user thread to one kernel
thread. What are the advantages and disadvantages of this
method over other methods?
Advantages
• The method enables creation of a separate kernel for handling each
of the user threads
• This method overcomes problems related to blocking of system calls
that processes splitting across various CPUs.
whereas parallelism refers to when tasks are processed simultaneously
b. There are two ways to support threads: kernel threads or user threads—
i. Most operating systems support both ways. Explain the advantages and
disadvantages of kernel threads and user threads,
Advantages of;
Kernel threads
• Efficient for applications that are often closed
• The application that has more threads is given more time
User threads
• Used by Operating System that does not take threads
• They are fast enough
• They are efficient since they are simpler
Disadvantages of;
Kernel threads
• They are not fast and are non -efficient
• They are complex
User thread
• The kernel and the operating system don’t work together
• They require calls so as not to block them
ii. Linux and Windows maps one user thread to one kernel
thread. What are the advantages and disadvantages of this
method over other methods?
Advantages
• The method enables creation of a separate kernel for handling each
of the user threads
• This method overcomes problems related to blocking of system calls
that processes splitting across various CPUs.

6
Disadvantages
• Overhead management is more complex due to the large number of
overheads which also slows down the system.
• It has a limit on the number of threads that can be created.
c. Consider the following code:
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
void *runAsThread(void *param);
int main() {
int i;
pthread_t tid;
pid_t pid;
for(i=0; i<3; i++) {
pid = fork();
pthread_create(&tid,NULL,runAsThread,NULL);
pthread_join(tid,NULL);
}
}
i. Explain what is happening within the for-loop. Your explanation must
include the purpose and the effect of the three system calls.
As the loop executes, fork() fox starts a new process, a new thread is created by pthread_create()
and finally it is terminated by pthread_join()
ii. Including the initial parent process, how many processes are created.
The loops repeat three times creating three processes
iii. How many unique threads are created? (Do not supply a number only, explain how
you came to your answer)
The network creates three threads as a result of the number of loops
that repeat themselves three times.
Question 4
Disadvantages
• Overhead management is more complex due to the large number of
overheads which also slows down the system.
• It has a limit on the number of threads that can be created.
c. Consider the following code:
#include <stdio.h>
#include <unistd.h>
#include <pthread.h>
void *runAsThread(void *param);
int main() {
int i;
pthread_t tid;
pid_t pid;
for(i=0; i<3; i++) {
pid = fork();
pthread_create(&tid,NULL,runAsThread,NULL);
pthread_join(tid,NULL);
}
}
i. Explain what is happening within the for-loop. Your explanation must
include the purpose and the effect of the three system calls.
As the loop executes, fork() fox starts a new process, a new thread is created by pthread_create()
and finally it is terminated by pthread_join()
ii. Including the initial parent process, how many processes are created.
The loops repeat three times creating three processes
iii. How many unique threads are created? (Do not supply a number only, explain how
you came to your answer)
The network creates three threads as a result of the number of loops
that repeat themselves three times.
Question 4
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide

7
a. What is the purpose of interrupts? Why are they a critical concept of modern
computers?
Interrupt is a type of signal that peripheral devices send to the
computer to notify it. Its function or purpose is to notify the system to
stop executing other processes and work on a specific part of the
operating system that is more urgent
Trap is a type of interrupt that is used to allow an input output device
to be removed in-case it has completed its work purposed
b. How does a trap differ from an interrupt?
An interrupt is often triggered by peripheral devices this includes the
input output devices and often executes after they have already
happened whereas a trap is a software generated signal that takes
places in the administrator’s processes. Often, the system awaits the
trap because it is dependent on it
c. Can traps be generated intentionally by a user program? If so, for what purpose? Give
examples.
Yes, a trap can be created deliberately and its meant to interfere. It can
be created by a hosted program
Examples of trap include;
The Breaking point, dividing a number by zero, accessing an invalid memory
d. What is the purpose of a timer? Why is a timer a critical component of modern
computers?
A timer is a type of clock used to measure the intervals of time. The events that take
place in a computer need to be monitored thus the work of the timer clock. The
purpose of the timer includes;
It keeps track of the events that takes place in a computer in that it will know
which will the very recent executed program
Management of resources in the computer
It automatically starts process in the computer
Monitors the logs in the computer
Performs recording of the events that takes place in the computers
a. What is the purpose of interrupts? Why are they a critical concept of modern
computers?
Interrupt is a type of signal that peripheral devices send to the
computer to notify it. Its function or purpose is to notify the system to
stop executing other processes and work on a specific part of the
operating system that is more urgent
Trap is a type of interrupt that is used to allow an input output device
to be removed in-case it has completed its work purposed
b. How does a trap differ from an interrupt?
An interrupt is often triggered by peripheral devices this includes the
input output devices and often executes after they have already
happened whereas a trap is a software generated signal that takes
places in the administrator’s processes. Often, the system awaits the
trap because it is dependent on it
c. Can traps be generated intentionally by a user program? If so, for what purpose? Give
examples.
Yes, a trap can be created deliberately and its meant to interfere. It can
be created by a hosted program
Examples of trap include;
The Breaking point, dividing a number by zero, accessing an invalid memory
d. What is the purpose of a timer? Why is a timer a critical component of modern
computers?
A timer is a type of clock used to measure the intervals of time. The events that take
place in a computer need to be monitored thus the work of the timer clock. The
purpose of the timer includes;
It keeps track of the events that takes place in a computer in that it will know
which will the very recent executed program
Management of resources in the computer
It automatically starts process in the computer
Monitors the logs in the computer
Performs recording of the events that takes place in the computers
Paraphrase This Document
Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser

8
One of the work of the OS is job scheduling, the timer shows how the various
events take place in the computer by showing which one was performed before
which one (Hudson et al., 2009).
One of the work of the OS is job scheduling, the timer shows how the various
events take place in the computer by showing which one was performed before
which one (Hudson et al., 2009).

9
References
Fjeldstad, Ø.D., Snow, C.C., Miles, R.E. and Lettl, C., 2012. The architecture of
collaboration. Strategic management journal, 33(6), pp.734-750.
Hudson, A., Hudson, P., Helmke, M. and Troy, R., 2009. Ubuntu Unleashed 2010 Edition:
Covering 9.10 and 10.4. Pearson Education.
References
Fjeldstad, Ø.D., Snow, C.C., Miles, R.E. and Lettl, C., 2012. The architecture of
collaboration. Strategic management journal, 33(6), pp.734-750.
Hudson, A., Hudson, P., Helmke, M. and Troy, R., 2009. Ubuntu Unleashed 2010 Edition:
Covering 9.10 and 10.4. Pearson Education.
⊘ This is a preview!⊘
Do you want full access?
Subscribe today to unlock all pages.

Trusted by 1+ million students worldwide
1 out of 9
Related Documents
Your All-in-One AI-Powered Toolkit for Academic Success.
+13062052269
info@desklib.com
Available 24*7 on WhatsApp / Email
Unlock your academic potential
Copyright © 2020–2025 A2Z Services. All Rights Reserved. Developed and managed by ZUCOL.





