MOD003218 Operating Systems Assignment Semester 2 | ARU
MOD003218 Introduction
This assignment is in two parts. Part 1 is an exercise where you need to write script programs in one or both of the MS-DOS batch language and the Linux bash shell scripting language. This will form 60% of the marks for this assignment (see below).
Part 2 is a set of research questions on the operating system you need to look up in textbooks or online, and write up your answers. This second part will form the other 40% of the marks. You need to attempt at least some of the programs in part 1 (ideally all!) AND the research questions in part
2. You will find it hard to pass if you do not at least attempt both parts.
MOD003218 Part 1: Scripting Task (worth up to 60%)
Write a JCL script in either MS-DOS batch or Linux bash script (or both if you wish, see the marking scheme later) which reads in a text file (as a command line parameter) with domain names and uses relevant commands (like nslookup or host) to find out corresponding IP addresses for each of the domains given by the user.
Read the following description to understand the requirements of the program.
1) In command line mode, the program should take exactly one parameter on the command line. The command line parameter is a filename of a text file. Read in that text file for a list of domain names, such as cisco.com, google.com or microsoft.com, each domain should be displayed in one separate line. The program should go through each line in the text file and call relevant commands (nslookup for MS-DOS command or host for Linux command) to show the corresponding IP address(s) for each domain.
2) If there is more than one line of domain names, the program will run in a loop until all lines are processed.
3) If the user did not provide any command line parameter, the program should display a main menu for the user to choose either (1) input a domain name or (2) quit from the program. If the user chooses (1), the program will prompt for a domain name from the user, it will then provide the corresponding IP address for that domain. After that, the program will return to the main menu until the user chooses (2) to quit the program.
4) The program should be user-friendly, and meaningful feedback should be given to the user whether the task has been successfully done or not.
For example, if the script you wrote was (for example, in MS-DOS) called “dns_lookup.bat” and at the MS-DOS command prompt you typed:
dns_lookup domain.txt
the program might result on the screen as follows:
Domain: cisco.com
IP Address: 72.163.4.185
—————————–
Domain: google.com
IP Address: 142.250.200.46
—————————–
Domain: microsoft.com
IP Address: 20.112.250.133
20.231.239.246
20.76.201.171
20.70.246.20
20.236.44.162
—————————–
when the domain.txt contains the following domain names:
cisco.com
google.com
microsoft.com
If the user inputted two command line parameters like:
dns_lookup list1.txt list2.txt
the program would say something like “Too many parameters entered”.
If the user did not input any command line parameter like:
dns_lookup.bat
the program would display a menu to the user for the choice of either to input the domain name or quit from the program:
Please select the option you want to proceed:
1) input a domain name
2) quit from the program
Your program should respond properly to every input from the user. If there is any wrong input from the user, your program should provide an appropriate error message.
The above is just an outline of how the program should work, it will need to be much more user friendly, such as the program introducing itself or producing error messages when the user provides wrong number of input parameters, etc.
Marks will also be given for making the program as robust as possible and doing appropriate checks such as considering what happens if the file name the user selects already exists and taking appropriate action. Note that deciding this is up to you, but you should be mindful doing appropriate and useful checks.
Useful hints to help you write the code to complete the exercises:
1. Read the material in chapters 2 and 3 of the module notes (JCLs parts 1 and 2) and complete the lab worksheets on MS-DOS and Linux and their JCLs. If you do not do this you will probably find the assignment very difficult! You may also want to look at the Vectorsite.net materials. All of these materials are on Canvas.
2. Research on how to read a file from the command line parameter (%1 for MS-DOS, $1 in bash) and how to get data from a file in the scripting languages.
3. Find out more about the “nslookup” or “host” commands. You will need to use a loop in your script to call the suitable commands with appropriate parameters and qualifiers. You also need to extract proper answers from the command call.
4. Think about how you will test your program. Just running it and thinking “ok that probably works” is not going to be enough. You need to make sure it works properly both when the information supplied by the user and the file environment is as expected and when it is not (such as if the user does not do as expected, or the file specified exists.).
5. Do not expect to be told very much on what tests you need to do (over and above what is given here). Part of the learning for this assessment is for you to work this out and decide what you think is needed!
You can choose if you wish to develop a solution to this task in one of MS-DOS batch language or Linux bash script or both. If you submit a solution with in only one scripting language (either MS- DOS or bash) you will be able to score up to 40% out of the available 60% for this aspect. If you choose to submit it in both scripting languages you can score up to the full 60%.
Hand in
Note – for full marks you will be expected to hand in ALL the things listed below. Failure to do so will result in lower marks even if your programs fully meet the above functional specifications. Marks will also be deducted for poor presentation and poor programming practice. Just handing in a disk with no printed report or a printed report and no disk will result in a low (possibly fail) mark.
When you hand in your work you should hand in the work for this task AND your answers to the “Research Questions” in one entire report to be uploaded to Canvas (see appendix 1 for more details of this).
By the deadline above, you must hand in a word report containing:
- Fully commented single spaced listings of your solutions to the scripting task. Minimally or uncommented and/or poorly laid out code is likely to score very low marks. Take care to check that Word does not mess up your code formatting (for example wrapping round code lines). Your code listing in the report should be actual text embedded in the Word document, not screenshots of the code from a CMD or bash window.
- The whole program flow should be explained clearly in your report. You may consider to use algorithms, flowchart or pseudocode to explain your program.
- Screenshots showing your programs running. Your screenshots should be annotated (indicating clearly what the screenshot demonstrates) and show that the programs work exactly as described above and include demonstrating any tests for unexpected situations you have built into your program.
- Think carefully what screenshots you show, they should be selected to show the various aspects and routes through the program all work correctly, random screenshots with little or no evidence of thought about the above or excessive screenshots where most or all do not aid proving the code works correctly are likely to score poorly. Remember the customer is always right …. It is no good implementing something other than what is asked for here or does not comply with the brief given here (including extra unnecessary features) and then trying to argue your way is better! What the customer wants, the customer gets even if you disagree with them…
- A bibliography list if you used any sources to help you develop your code cross referenced where needed to your report (including references in the research questions). If you are unclear how to reference properly there is a guide to how on the ARU Library website. It is not essential you use a specific style but you should use a recognised referencing style such as Harvard. If you directly used code from another source then this should also be stated in the comments in your programs.
- A word file or pdf file containing both parts of the answers in your Word report together with the script file(s) should be submitted before the deadline. Please name your text files so
that it is obvious what they are. See appendix 1 about your files for submission. If you only include the Word document and do not include the script file(s) you will lose all the marks for the marker testing your code which could mean you fail.
Tips:
Keep an electronic backup of all submitted work in case there are problems with the submission.
Make sure your Word document contains all the required information including the source codes and is readable (please check this!). Do not encrypt it! If we cannot open your file (for example it is corrupted) we will be unable to test your code and/or check your Word document we will give you zero for that aspect.
Please make sure what you hand in is clearly your own work. If you use code or material from other sources (including the lecture notes) this should be made clear in the code comments or in your research question answers. Submissions suspected of plagiarism will be passed to the Director of Studies (DOS) for investigation.
Mark Scheme Breakdown (out of the 60% for this section):
Aspect |
Maximum marks if you submit a solution in just ONE scripting language (MS-DOS or bash). |
Maximum marks if you submit solutions in both scripting languages. |
Well designed and written code which works as described above (including good code layout, error checking and commenting). |
25% |
40% |
Appropriately selected screenshots which are legible and fully demonstrate the operation of the code. |
10% |
15% |
Presentation of the report and referencing |
5% |
5% |
Total Possible Marks (out of 60%) |
40% |
60% |
Part 2: Research Questions (worth 40%)
Instructions/Information – Please Read This Carefully: You should hand in your answers to these questions in the same Word report as the code and screenshots etc. described above.
- You should include the question text and question number in the report with the relevant answer. Copy the questions exactly, do not paraphrase or alter the text.
- All questions are worth the same (8 marks, so answers to five questions make a total of 40%). You are only expected to write fairly short answers per question, typically two or three paragraphs.
- You should attempt all questions. Make sure you answer the question asked, only the question and nothing but the question. Writing about something other than what the question asks, however correct, wastes your time and will get no marks.
- All answers should be your own work and written in your own words, if you use information from other sources please reference it using an appropriate referencing style (see part 1 above for more details on how to reference and where to get more information on referencing).
- Answers which are clearly just “cut and paste” text from websites (even if referenced) with little or not attempt to summarise or paraphrase will consider as “plagiarism” or academic misconduct.
Questions:
1. Describe the life cycle of a process, using diagrams, with details about each state. Write down the conditions that a process is switched:
(i) from Ready state to Running state
(ii) from Running state to Ready state
2. Shortest Job First (SJF) is a relatively simple CPU scheduling algorithm for process management. Consider that there are two busy multi-programming systems A and B.
The new processes created on System A are mostly long CPU burst processes with only occasional short CPU burst processes. The new processes created on System B are mostly very short CPU burst processes.
(i) State whether process starvation is likely to occur on either or both System A and System B.
(ii) If process starvation occurs on System A, state which type of processes is likely to be starved. Similarly, if process starvation occurs on System B, state which type of processes is likely to be starved. Your answer should refer to relevant characteristics of SJF algorithm.
3. Consider the kitchen example and you are now the manager of the kitchen.
There are 3 bowls, 2 stirrer, and 1 measuring cups in the kitchen. There are 3 chefs working in the kitchen. Chef C1 is holding 2 bowls, 1 cup, and needing 1 stirrer. Chef C2 is holding one bowl, one stirrer, and needing one cup. Chef C3 is holding one stirrer and needing one stirrer.
(i) There will be bad consequences when a deadlock occurs in the kitchen. Your boss is very concerned and ask you in theory the conditions for deadlock to occur. Answer your boss.
(ii) Draw a Resource Allocation Graph (RAG) to describe the resource allocation situation outlined above.
(iii) Based on your RAG and discuss if a deadlock has occurred or the situation concerning deadlock.
(iv) In a real computer system, what will be the chefs, bowls, cups, stirrers represented for? Justify your answers with reasons.
4. Consider an online computer system booking system for air tickets. It is expected that thousands of customers are using the system at the same time. A customer typically spends around 10 minutes to complete the querying, booking, and payment processes. Normally customers access the booking systems using a smartphone application that communicates with a web server for almost every operation.
(i) One design decision is about selecting the most suitable CPU scheduling algorithm for the server. In the evaluation, suggest the performance metric that is most relevant? Justify your answer.
(ii) To support more and more customers, the server needs an upgrade. Suggest whether it is more important to increase the size of the main memory or using a more powerful CPU. Justify your answer.
(iii) Study the following article. Based on the information given in the article, discuss if web caching is a suitable solution to achieve the performance metric you answered in part (i).
5. In this question, you are asked to complete the two following questions given in the practical exercises. Program code with comments and explanation should be given in the Word report.
(i) Write a MS-DOS batch program which prompts the user for the name of a batch file, checks it exists (outputting an error and stopping if it does not) then goes on to ask the user for the author of the batch file’s name. It then adds two comment (rem) lines to the start of the batch file the first says “Written by” and the author’s name and the second the date and time. When it finishes the batch file should still be runnable with no errors!
(ii) Write a bash script that uses a looping menu and case statements to perform a range of simple file operations. For each option the user is prompted for the correct number of parameters for the specific command and where necessary verifies the files/directories exist or not as appropriate. Option 1 is to copy one file to another, option 2 to rename one file to another, option 3 to create a directory and option 4 quit.
Appendix 1: Submitting relevant files for your assignment
As indicated above, you need to submit a Word (or pdf) report together with the scripts.
These instructions assume you have completed your single Word report (containing the imported code listings, screenshots and your answers to the research questions) and you have extracted your script files from the VM(s) as needed as described in the document (p.8-9) you can find on Canvas here.
For example: You should submit these files to the “Assignment” section in Canvas. One word file for the report, one MS-DOS batch file and one bash script. You will have your own filenames, the ones here are just examples you should name your files to match their purpose:
