You are on page 1of 2

ADEOYE Victoria

=== Preliminary work : understanding the threads you already created ====

0 - copy the function “printThreadsInfos(“text”) from the Main.java file in the code you made last
time with Georges Da Costa (the scheduling of processes) and understand the different states of the
threads you created (Use the function printThreadsInfos at different place in your code).

===============================

Now, lets start the understanding of periodic tasks, ThreadPools and Runnable in Java ====

1 - compile and run the program as it is (javac Main.java, then java Main).

 Done.

2 - how many threads are created by the program and run concurrently at the same time ?

 Four (4) threads were created by the program. 1 active thread and 3 queued tasks

3 - Use different size of ThreadPool. Conclude about its utility and usage, and come back to the
previous question to answer properly.

 Usage initially was 452528 and remained the same as I had only one core running on my
virtual machine.

3bis - Fix the size of the schedule pool back to 1.

 Done

4 - Schedule the task th3 according to the instruction in the code

 ScheduledFuture<?> beeper = scheduler.scheduleAtFixedRate(th3, 20, 2,


java.util.concurrent.TimeUnit.SECONDS);

5 - Schedule a task th4 (after creating it, meaning finishing the coding of the class…) according to the
instructions in the code

 Thread th4 = new Thread(new CancelPeriodicThread(beeper), "CancelPeriodicThread");

scheduler.scheduleAtFixedRate(th4, 20, java.util.concurrent.TimeUnit.SECONDS);

6 - Uncomment the 2 lines with the sched Thread. What are you doing by uncomment these two
lines?

 Done

7 - Check the code of the class Sched, and understand its behaviour

 Its running in parallel

8 - In this question, we will not use the th0, th1, th2, … that were created for TP2. Comment them
out in the code.

The aim is to adapt your work of last time with Georges so that it uses the mechanism of scheduler
in order to use/reorder the queues, and to use real times values.
The idea of the sched is to manage the tasks in a queue

8.1 - Create N simple Processes (without Conditions for the moment), and ask the scheduler
object to execute them (scheduler.execute())

 Done

8.2 - Run the program and see in which order the Processes are executed. What is the
algorithm used by the scheduler object ?

 Done, the scheduler is using OPTI algorithm

8.3 - In this case, the Processes are running actually on real times. Compute the deadline
misses.

8.3 - In this question, the sched Thread is responsible for the reordering of the scheduler
queue (it has indeed access to the scheduler queue (see question 6 and 7). Re-Implement the Round
Robin, the EarliestDeadlineFirst and Optimal in this framework. You might have to use the
Conditions, Locks, and/or Exception/Interruption for this.

9 - how to change your sched implementation so that it can integrate the scheduling of the periodic
tasks (th1, th2, th3, th4) ?

smart algorithm to solve periodic task – so we don’t miss a task

You might also like