Verification of thevenin's theorem for BEEE Lab (1).pptx
Lab 1 izz
1. NMJ 42304 REAL TIME SYSTEM
SEMESTER I
(2021/2022)
LAB 1 : DELIVERABLES
NAME MATRIC PROGRAM
NUR IZZATY BINTI MOHAMAD ASRI 181021143 RK 20
2. In Linux machine, implement the static scheduler of the given in the table, of the following set of
task T1= (4, 1.0) ,T2 = ( 5, 1.8), T3= (20, 1.0), T4= (20, 2.0), (units in seconds) where the hyper
period is 20 seconds.
CODE :
#include <stdio.h>
#include <time.h>
void delay(float delayTime)
{
float milli_seconds = 1000 * delayTime;
clock_t start_time = clock();
while (clock() < start_time + milli_seconds);
}
int task1(int x , int y)
{
int sum;
clock_t t = clock();
sum = x+y;
printf("result for sum is = %dn", sum);
delay(1000);
t = clock() - t;
3. double time_taken = ((double)t)/CLOCKS_PER_SEC;
double time_taken_in_microsec = time_taken * 1000000;
printf("task1() execution time = %.2f sn", time_taken);
printf("task1() execution time = %.1f msn", time_taken_in_microsec);
}
int task2(int x, int y)
{
int sub;
clock_t t;
t = clock();
sub = x-y;
printf("result for sub is = %dn", sub);
delay(1800);
t = clock() - t;
double time_taken = (double)(t)/CLOCKS_PER_SEC;
double time_taken_in_microsec = time_taken * 1000000;
printf("task2() execution time = %.2f sn", time_taken);
printf("task2() execution time = %.1f msn", time_taken_in_microsec);
}
4. int task3(int x , int y)
{
int multiply;
clock_t t;
t = clock();
multiply = x * y;
printf("result for multiply is = %dn", multiply);
delay(1000);
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC;
double time_taken_in_microsec = time_taken * 1000000;
printf("task3() execution time = %.2f sn", time_taken);
printf("task3() execution time = %.1f msn", time_taken_in_microsec);
}
int task4(int x , int y)
{
int devide;
clock_t t;
5. t = clock();
divide = x / y;
printf("result for devide is = %dn", devide);
delay(2000);
t = clock() - t;
double time_taken = ((double)t)/CLOCKS_PER_SEC;
double time_taken_in_microsec = time_taken * 1000000;
printf("task4() execution time = %.2f sn", time_taken);
printf("task4() execution time = %.1f msn", time_taken_in_microsec);
}
void delaySlackTime(int passByRef)
{
clock_t t;
t = clock();
delay(passByRef);
t = clock() -t;
double time_taken = ((double)t)/CLOCKS_PER_SEC;
printf("DelaySlackTime() execution time = %.2f sn", time_taken); }
int main()
9. DESIGN:
As an discussion, we consider a system that contains four independent periodic tasks. . They
are T1 = (4, 1), T2 = (5, 1.8), T3 = (20, 1), and T4 = (20, 2). Their utilizations are 0.25,
0.36, 0.05, and 0.1, respectively, and the total utilization is 0.76. It suffices to construct a
static schedule for the first hyperperiod of the tasks. Since the least common multiple of all
periods is 20, the length of each hyperperiod is 20. The entire schedule consists of replicated
segments of length 20.