THINK FIRST·CODE LATER

← All labs

Deadline- and cost-aware placement across device, edge and cloud

Problem

Input: the number of resources, then per resource name speedGHz transferMsPerMB rttMs pricePerGcycle; then tasks name release deadline gigacycles MB (times in ms) until the end of input.

Process tasks in EDF order (deadline, then release time, then input order). Each resource executes one task at a time. For task t on resource k: arrival = release + MB × transferMsPerMB + rtt; start = max(arrival, time when k becomes free); finish = start + gigacycles / speed × 1000.

Choose the cheapest resource (price × gigacycles) whose finish ≤ deadline (ties → first resource); if none, choose the resource with the earliest finish (first on ties) and mark the task MISSED. The chosen resource becomes free at the task's finish time.

Print T2 -> edge, finish 65 ms, deadline 70 met, cost 0.40 per task (times as integers when whole, else 1 decimal; cost 2 decimals) and Deadlines met: m/n, total cost X.

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

os13-4-data-1.txt

3
phone 2 0 0 0
edge 20 80 5 1
cloud 50 80 60 0.4
T1 0 100 0.1 0.2
T2 0 70 0.4 0.5
T3 10 300 2 1
T4 20 80 0.2 0.1
T5 20 90 0.3 2
T6 30 120 0.6 0.5
What your program must print for os13-4-data-1.txt
T2 -> edge, finish 65 ms, deadline 70 met, cost 0.40
T4 -> edge, finish 75 ms, deadline 80 met, cost 0.20
T5 -> phone, finish 170 ms, deadline 90 MISSED, cost 0.00
T1 -> cloud, finish 78 ms, deadline 100 met, cost 0.04
T6 -> edge, finish 105 ms, deadline 120 met, cost 0.60
T3 -> cloud, finish 190 ms, deadline 300 met, cost 0.80
Deadlines met: 5/6, total cost 2.04

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < os13-4-data-1.txt

Windows PowerShell does not understand <:

Get-Content os13-4-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.