当前位置:天才代写 > C++/C代写,c语言代写代考-100%安全,包过 > programming代写 AVA Runnable代写 JAVA Thread Class代写

programming代写 AVA Runnable代写 JAVA Thread Class代写

2020-11-16 17:47 星期一 所属: C++/C代写,c语言代写代考-100%安全,包过 浏览:1539

programming代写

COMP604: Operating Systems

programming代写 Things you should know:This assignment contributes 30% towards overall of your course marks. In this assignment

Semester 2, 2019

Assignment programming代写

Due Date: 04-Oct-2019 (till 5:00pm)

Things you should know:

This assignment contributes 30% towards overall of your course marks. In this assignment you will be asked to implement some of the concepts and skills you have learned in this course. You may be required to do some research as well but, please be aware of AUT’s plagiarism and cheating policies.

Late submission penalty is applied with a 5% deduction per day. If you submit the assignment more than 5 days late, then you will be awarded 0 marks.programming代写

This is a team or individual assignment: The assignment is intended to be a team assignment for teams of two. However, if you feel it inconvenient to do this as a team, you are free to choose to submit an individually worked assignment. For those who feel a bit “challenged” with programming due to their major’s nature, this is a chance to team up with somebody more comfortable with programming.

This assignment consists of three tasks and all tasks are mandatory.

Task1: Shell scripting programming代写

Objective: The objective of this task is to develop basic shell scripting skills with parameter handling.

You are required to write a shell program/script to concatenate data from two files. Your program should perform the following:

a.Your script should start executing by greeting the user and displaying the information about its usageg.,

“Welcome user <username>.programming代写

This is ./concatenatefile.sh script file. You are required to enter names of two text files and the program will concatenate those files and generate an output.txt file”.

b.Check the no. of parameters passed by the user. If the user inputs incorrect no. of parameters or the files name entered does not exist; your program should display the error message and

c.Program should correctly concatenate data of the two files and save it into a new file named output.txt and generates a success

Assumption: Consider the input files are in the same directory as that of your concatenatefile.sh.

programming代写
programming代写

Task2: Banker’s Algorithm [1] programming代写

Objective: The objective of this task is to develop a better understanding of multithreading.

Overview:

Banker’s Algorithm is used by many Operating Systems to avoid deadlock and handle resource allocation properly. This algorithm works based on the following three factors:

  1. What is the maximum no. of requests each process can make for each resource?
  2. How much each resource is currently allocated to eachprocess?
  3. Howmuch each resource is currently available (free for use) with the operating system?programming代写

Rule

Resource will be allocated to the requested process if and only if the no. of resources requested are currently available (free for use) with the operating system.

System Implementation:

As, all the customers will be sharing the available resources yet having the record of their individual allocated resources, we can use Threads to implement this problem. We are going to implement Banker’s Algorithm using JAVA Thread Class (you can use JAVA Runnable or PThreads in C/C++ if you desire).programming代写

We will be maintaining the record of total available resources of each type with the system, the number of each type of resources occupied by each customer. Method requestResource will be used to assign the requested resources to the relevant customer IF the Rule (explained in the above section) permits. With each served request a thread will be created and start functioning. For the assignment purpose, leteach thread sleep for some random time before exiting. On exiting, thread will release the resource it was occupying.programming代写

Another method releaseResource will be used to release a resource. Once the resource is released, it will be returned to the pool of available resources. The method should also print the current status of the overall system resources.

The following program structure and steps may be helpful in completing this task.
o Create and start thread corresponding to each resource assigned to the customer

· IF rule() function returns failure

o Display appropriate message for the customer and advice to wait till the requested resources are available

rule()

· Check the rule criteria for the requested no. of resources

· Return true or false accordingly programming代写

releaseResource()

· Takes the resource from the customer and put it in the currently available resources to be used by other customers on request

· Print the status of the currently available resources

run() function/method in the class that extends Thread class

· Should be called when each Thread starts

· Let each thread sleep for some random sleep time

· When awake, call the releaseResource() function

· exit

Test Run: programming代写

Run your program using the following values to test your program. Copy your result and paste it in the readme.txt file under the heading “Test Run Results”.

int customerNo = 5;

int resourceNo = 3;

//how many resources are already allocated to each customer

int[][] reserved = new int[customerNo][resourceNo];

//maximum how many resources each customer can request for

int[][] max = new int[customerNo][resourceNo];

//currently available resources programming代写

int[] available = new int[resourceNo]; //set availability of all resources to 20

References:

  • https://en.wikipedia.org/wiki/Banker%27s_algorithm

Task3: Traffic Light Problem

Objective: The objective of this task is to develop a better understanding of process synchronization and deadlock handling.programming代写

Overview:

Traffic light problem is a classical example of synchronization and deadlock handling. We have discussed during our lecture (Week-5) a Petri Nets model for handling this problem. The Petri Nets model is also given below for your reference:

programming代写
programming代写

Fig.1. Petri Nets for Traffic Light

You are required to write a JAVA or C code to implement this Petri Nets model.

Clearly mention in your code (using comments) the piece of code you have written to address the synchronization and deadlock handling.

Your program should be able to:

  1. Ask the user which traffic light it wants to be
  2. Allow that traffic flow for a fixed time of 5 seconds and then stops both traffic flows and repeat (a)programming代写

Submission Guidelines:

  • Youare required to submit a single zip file containing three folders (one for each task) on Blackboard before the due date and
  • Please make sure that you have added a “readme.txt” file for both the tasks, mentioning thefollowing:
    • State if it’s a team or individual work. If it’s a teamwork, please givethe name and student number of your team
    • A list of all the files in thedirectory
    • A brief instruction on how to compile and run theprogram(s)
    • Your answer to Test Run for programming代写

Marking Guide:

Tasks Criteria Allocated Marks
General a. Comments and readme file 5
b. Quality of code (Whitespace, Naming, Reuse, Modularity, Encapsulation) 5
Sub-Total 10
Task-1 a. Welcome message 2
b. Getting input 2
c. Displaying error message on wrong input 2
d. Correct generation of the output.txt file 4
Sub-Total (Task-1) 10
Task-2 a. Main function/method 4
b. requestResource function 6
c. releaseResource function programming代写 4
d. Rule function 4
e. Use of multithreading 2
f. Thread run function 5
g. Running and output 5
Sub-Total (Task-2) 30
Task-3 a. Main function 4
b. Taking appropriate input 2
c. Deadlock and Synchronization handling 10
d. Time of traffic flow and again asking for input 4
Sub-Total (Task-3) 20
 

TOTAL

 

70

programming代写
programming代写

更多其他:C++代写 考试助攻 C语言代写 finance代写 lab代写 计算机代写 code代写 report代写 project代写 物理代写 数学代写 经济代写  java代写 编程代写

合作平台:天才代写 幽灵代写 写手招聘 Essay代写

 

天才代写-代写联系方式