You are on page 1of 4

Assignment 1: 15%

Due Date: 20th March 2020, 4pm


Learning Outcomes: Solve synchronization problems inherent in inter-process communication
and multi-threaded applications

There are two programming questions in this assignment. Both questions are compulsory. This
assignment needs to be completed individually.

Question 1
Write a program i.e. is a version of a shell that can take command(s) from the user and execute
them on behalf of the user (by spawning a child process to execute the command on behalf of
the parent process). It can only execute a few commands as listed below:

[+] mkdir <file 1> [<file 2> ... <file n>]


[+] ls [<dir>]
[+] cp <source> <dest>
[+] mv <file 1> [<file 2> ... <file n>] <dest>
[+] vi <file>

where parameters enclosed in [] are optional parameters.


Note that multiple commands are recognized by the shell if each command is delimited by
";". These commands will be executed one after the other.

The C program that will act as a shell interface which should accept and execute each command in
separate process. There should be a parent process that will read the command and then the parent
process will create a child process that will execute the command. The parent process should wait for the
child process before continuing. Your program should mimic Linux terminal. This program should be
written in C and executed in Linux. You are required to implement five commands out of which one
command should be the editor. The program design is entirely up to you but make sure that your shell
interpreter is easy to modify.
Question 2
Using the knowledge related to Pthreads, write a multithreaded program that outputs prime numbers.
The program requirements are:

 The user will run the program and will enter a number on the command line.
 The program will then create a separate thread that outputs all the prime numbers less than or
equal to the number entered by the user.
 The main thread has to wait for all child threads created to exit before termination.

Submission Guidelines

 This assignment is to be completed individually.


 Submit only one zip file which has programs.
 Only one submission is required – rename the file as your id number.
 A softcopy of your assignment should be submitted through Moodle Drop Box using.
 Incorrect/incomplete submissions or any assignments caught as plagiarized work will receive a
mark of zero (0).
 Late submissions will not be accepted unless prior arrangements have been made with the
lecturer and supplemented by documentary evidence.
 Do not submit any piece of assignment work on Moodle Discussion Forums.
Marking Rubric

Overall Unsatisfactory Satisfactory Good


Programming I. Plagiarism I. Able to write I. All satisfactory
II. Poor a complex and
indentation, code for a demonstrate
hard to read loosely very good
and follow the defined programming
code problem skills.
III. Lots of bugs II. Appropriate
and/or errors structure of
IV. Program the program
produces III. Use of
unexpected standard
output programming
V. No exception practices such
handling as modularity,
VI. Hard coding of low coupling,
data in the high cohesion
program. etc.
VII. Poor structure IV. Appropriate
encapsulation,
inheritance or
polymorphism
for object-
oriented
programming.
V. computer
program
produces
expected
output
VI. appropriate
exception
handling

2 points 7 points 10 points


The program
works and
The program
produces the
works and The program
correct results
The program produces some works very
and displays
does not meet correct results. well. Meets all
them correctly.
Q1 the Meets some specification.
NOne Meets most
Program specification. specification. All commands
0points specification.
Design 2points 3 commands work perfectly
Most of the
work. 10points
commands
Rubric I - VII 5points
works.
Rubric I
8points
Rubric I - VII
Rubric I- VI
The code is
The code is readable only The code is
poorly by someone The code is exceptionally
Q1
None organized and who knows fairly easy to well organized
Program
0points very difficult what it is read. and very easy
Readability
to read. supposed to be 3points to follow.
1points doing. 4points
2points
The program
The program
The program works and
works very
The program works and produces the
well. Meets all
does not meet produces some correct results
specification
Q2 the results. Meets and displays
None including
Program specification. some them correctly.
0points usage of shared
Design 2points specification. Meets most
memory.
5points specification.
10points
Rubric I - VII 8points
Rubric I - VII
Rubric I
Rubric I- VI
The code is
The code is readable only The code is
poorly by someone The code is exceptionally
Q2
NOne organized and who knows fairly easy to well organized
Program
0points very difficult what it is read. and very easy
Readability
to read. supposed to be 3points to follow.
1points doing. 4points
2points

You might also like