Parallel System Assignment
Parallel System Assignment
Parallel System Assignment
ADMINISTRATION
EMAIL: treymaxsikanyi@gmail.com
QUESTION 1:
Note: For the following questions write the UNIX commands and execute either by
using Cygwin or Linux and attach the screenshots of the output. Only theory answers
will not be counted for the marks
a) When you log in, a program starts executing at your terminal. What is the program
known as?
ANSWER
The Program is known as the shell
b) Name four types of this program that are available on a system?
ANSWER
i. Bash (The boune again shell)
ii. Ksh (The korn shell)
iii. Sh(The bourne Shell)
iv. Csh (The C shell)
c) What is the one thing that is common in directories, devices, terminals and printers?
Everything are treated as file in the Unix including the kernel
d) Name some of the duties of the system administrator that you have encountered in
UNIX programming?
i. Installing and upgrading UNIX system software on campany servers and
computers
ii. Creating UNIX file systems
iii. Setting up and maintaining UNIX user accounts access management
systems
iv. Implementing networks and computer system policies
e) A program file named foo exists in the current directory, but when we try to execute it
by entering foo ,we see message foo : command not found .Explain how that can
happen?
EXPLANATION
Foo is an argument not a command . Arguments are not recognized unless they are
used together with command because command are recognized in the unix operating
system for example cat can be used together with fool in order to display the content.
Therefore when you just type fool command not found.
a) Assuming that you are positioned in the directory /home/Romeo, what are these
commands presumed to di and explain whether they will work at all:
(i) cd ../..
(ii) mkdir ../bin
(iii) rmdir ..
(iv) ls ..
Answer
EXPLANATION
1.) Well the first command is used to change directory to parent/root and it goes up one
level .Therefore cd ../.. command is used to change directory to parents parent
directory that is it goes up two levels.
2.) mkdir ../bin definitely this command cannot work reason being that The /bin
Director is a standard subdirectory of the root directory in Unix operating systems that
contains the executable files (i.e., ready to run) unless you are root
3.) rmdir .. this command as well will not worked because the root directories has
content in it so we can’t remove it that is why it is saying the directories is not
empty.
4.) This will definitely work as you can see on the picture it will just list all the contents
of the current directory.
Suppose you have to develop script that refers to a file in Charlie’s home directory. How will
you specify the location of this file in your script to make sure that it works even when
Charlie’s home directory changes?
ANSWER
Charlie uses /usr/Charlie as home directory, and many of his scripts refer to the
pathname/usr/Charlie/html. Later, the home directory is changed to/home/Charlie, thus
breaking all his scripts. How could Charlie have avoided this problem?
The way that Charlie could avoided this problem would have been by adding the
directory “html” to the end of path which in return would have prevented all of his
script from being brocken
b) The command rmdir bar fails with the message that the directory is not empty. On
running ls bar , no files are displayed. Why did the rmdir command fail?
c)
ANSWER
EXPLANATION
The command refuse to delete as it is shown in the image above because the
content inside the bar files are hidden files so if you type ls to check the directory
it will show you nothing but after type the command ls -la which lists everything
including the hidden file .the file shows up as treysons
The second way is to use the command rm -r to delete everything including the
hidden files
d) Run the script command and then issue a few commands before you run exit what do
you see when you run cat -v typescript
f) A files current permission is r w – r – x r - -. Specify the chmod command required to
change them for the following. Using both relative and absolute methods of assigning
permissions
(i) - w-r--r--
(ii) r--r-----
(iii) rwxrwxrwx
(iv) ---------
ANSWER
QUESTION 2:
Note: For the following questions write the UNIX commands and execute either by
using Cygwin or Linux platform and attach the screenshots of the output. Only theory
answers will not be counted for the marks
a) The wc command was designed to count characters, lines and words only in the files.
Explain whether the statement is true or false with a suitable example (write a command
and show with the help of screenshot)
ANSWER
wc - print newline, word, and byte counts for each file .therfore the statement is
TRUE as it is shown on the picture
So my conclusion is that you cant change using the date command to change the system
date. It can only show the current time and date
c) Observe the calendar for the year 1752. Do you notice anything unusual? How will
you browse the output of this moving forward and backward as necessary
ANSWER
Yes I have noticed something strange about September some days are missing from 2 to
14th date
Secondly you can output the calender by using the following commands
1.) Cal 1752 | more OR
2.) Cal 1752 | less
Using space or f move one page forward
Using b move one page back
For less
Space or f or z move one page forward
Using b move one page back
After writing the script must include the code stty -echo . what this code does is
that it doesn’t allow the terminal t accept the input.
You can revert the settings simply by typing the command stty echo
e) Both your local and remote machines use identical versions of UNIX. How do you
confirm whether you are logged on to a remote machine or not ?
ANSWER
who am i and uname -n command and ENTER will display the logged-in
user name and current tty details. The output of this command contains
the following columns: logged-in user name, tty name, current time with
date and ip-address from where this users initiated the connection.
f) Which of these commands will work? Explain with reasons
(i) mkdir a/b/c
(ii) mkdir a a/b
(iii) rmdir a/b/c
(iv) rmdir a a/b
(v) mkdir /bin/foo
ANSWER
(vi) mkdir a/b/c command will only work only if there is a directory a that
contains a directory b and it exists in the current directory. Then when
the command is run, it will create a new directory c in directory b.
(vii) mkdir a a/b command will only work if the directory ‘a’ does not exist in
the working directory. This command is similar to the following
command_mkdir a, mkdir a/b. This command will create a directory in
the current directory and then b that is sub directory is created inside a.
(viii) rmdir a/b /c just like in(i), rmdir a/b/c command will only work if a
directory ‘a’ exists in the current working directory and also contains
sub- directory b and b further contain subdirectory c. if c is empty this
command will execute otherwise this will result in failure
(ix) rmdir a a/b will always fail. It only functions successfully if the target
directory is empty. Let us assume that the directories a and b exists and b
contained in a. When the command is run, the first part that is rmdir a
will fail as the directory is not empty. If the directory a is empty the first
part will succeed. But after deleting a and b both does not exist, so second
part will fail. Hence the command will fail in any other way.
(x) Mkdir /bin/foo command will run successfully if there exists a directory
bin under te main root directory. And only if the file created is executable
because all the file in the bin directory are all executable. The command
will fail if it already contained a subdirectory named foo
ANSWER
// keep the code Change the name “treysonz”
QUESTION 3:
a) Control hazards can cause a greater performance loss for our MIPS pipeline than do
data hazards. When a branch is executed, it may or may not change the PC to
something other than its current value plus 4. Recall that if a branch changes the PC to
its target address, it is a taken branch; if it falls through, it is not taken, or untaken. If
instruction i is a taken branch, then the PC is normally not changed until the end of
ID, after the completion of the address calculation and comparison.
Answer
yes
ii) If so, explain with the help of simplified version of a RISC data path
drawn in pipeline fashion.
answer
iii) And also explain how the branch hazard can be resolved? Explain with
branch taken and branch not taken technique
Answer
• Branch taken
– Wait 3 cycles"
– Time lost"
• One approach:
QUESTION 4:
Assignment Problem—The Sleeping Teaching Assistant
A university computer science department has a teaching assistant (TA) who helps
undergraduate students with their programming assignments during regular office hours. The
TA’s office is rather small and has room for only one desk with a chair and computer. There
are three chairs in the hallway outside the office where students can sit and wait if the TA is
currently helping another student. When there are no students who need help during office
hours, the TA sits at the desk and takes a nap. If a student arrives during office hours and
finds the TA sleeping, the student must awaken the TA to ask for help. If a student arrives
and finds the TA currently helping another student, the student sits on one of the chairs in the
hallway and waits. If no chairs are available, the student will come back at a later time.
Using POSIX threads, mutex locks, and semaphores, implement a solution that
coordinates the activities of the TA and the students. Details for this assignment
are provided below.
Using Pthreads, begin by creating n students. Each will run as a separate thread.
The TA will run as a separate thread as well. Student threads will alternate
between programming for a period of time and seeking help from the TA. If
the TA is
available, they will obtain help. Otherwise, they will either sit in a chair in the
hallway or, if no chairs are available, will resume programming and will seek help
at a later time. If a student arrives and notices that the TA is sleeping, the student
must notify the TA using a semaphore. When the TA finishes helping a student,
the TA must check to see if there are students waiting for help in the hallway. If
so, the TA must help each of these students in turn. If no students are present, the
TA may return to napping.
Perhaps the best option for simulating students programming—as well as the
TA providing help to a student—is to have the appropriate threads sleep for a
random period of time.
POSIX Synchronization
Required
Answer
Hangout_1.c
Help_Student
Student_1.c
ta.c
ta.h
Make_file_ 1_2_3_4 file