SlideShare ist ein Scribd-Unternehmen logo
1 von 9
NMJ 42304 REAL TIME SYSTEM
SEMESTER I
(2021/2022)
LAB 1 : DELIVERABLES
NAME MATRIC PROGRAM
NUR IZZATY BINTI MOHAMAD ASRI 181021143 RK 20
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;
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);
}
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;
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()
{
clock_t d;
d = clock();
while(1){
task1(2,2);
task3(4,5);
task2(2,2);
delaySlackTime(200);
task1(2,2);
delaySlackTime(1000);
task4(6,6);
task2(2,2);
task1(2,2);
delaySlackTime(1000);
task2(2,2);
task1(2,2);
delaySlackTime(1200);
task1(2,2);
delaySlackTime(1000);
task2(2,2);
delaySlackTime(200);
d = clock() -d;
double time_taken = ((double)d)/CLOCKS_PER_SEC;
printf("total time taken = %.2f sn", time_taken);
}
}
OUTPUT :
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.

Weitere ähnliche Inhalte

Ähnlich wie Lab 1 izz

Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Task4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docxTask4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docx
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
josies1
 
Military time and Standard time, JavaOne of the assignments given .pdf
Military time and Standard time, JavaOne of the assignments given .pdfMilitary time and Standard time, JavaOne of the assignments given .pdf
Military time and Standard time, JavaOne of the assignments given .pdf
marketing413921
 
Modify the Time classattached to be able to work with Date.pdf
Modify the Time classattached to be able to work with Date.pdfModify the Time classattached to be able to work with Date.pdf
Modify the Time classattached to be able to work with Date.pdf
aaseletronics2013
 
operating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdfoperating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdf
aptcomputerzone
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
anishgoel
 

Ähnlich wie Lab 1 izz (20)

Write Python for Speed
Write Python for SpeedWrite Python for Speed
Write Python for Speed
 
2 презентация rx java+android
2 презентация rx java+android2 презентация rx java+android
2 презентация rx java+android
 
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Task4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docxTask4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docx
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
 
C++ L08-Classes Part1
C++ L08-Classes Part1C++ L08-Classes Part1
C++ L08-Classes Part1
 
Eulode
EulodeEulode
Eulode
 
Military time and Standard time, JavaOne of the assignments given .pdf
Military time and Standard time, JavaOne of the assignments given .pdfMilitary time and Standard time, JavaOne of the assignments given .pdf
Military time and Standard time, JavaOne of the assignments given .pdf
 
Modify the Time classattached to be able to work with Date.pdf
Modify the Time classattached to be able to work with Date.pdfModify the Time classattached to be able to work with Date.pdf
Modify the Time classattached to be able to work with Date.pdf
 
FS2 for Fun and Profit
FS2 for Fun and ProfitFS2 for Fun and Profit
FS2 for Fun and Profit
 
Microkernel Development
Microkernel DevelopmentMicrokernel Development
Microkernel Development
 
Snake.c
Snake.cSnake.c
Snake.c
 
Dive Into PyTorch
Dive Into PyTorchDive Into PyTorch
Dive Into PyTorch
 
algorithm design file
algorithm design filealgorithm design file
algorithm design file
 
Java Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type ConversionJava Foundations: Data Types and Type Conversion
Java Foundations: Data Types and Type Conversion
 
C vs Java: Finding Prime Numbers
C vs Java: Finding Prime NumbersC vs Java: Finding Prime Numbers
C vs Java: Finding Prime Numbers
 
Ch2
Ch2Ch2
Ch2
 
I os 06
I os 06I os 06
I os 06
 
y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx
 y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx
y Bookmarks People Window Helo Online Derivative edusubmi tionassig.docx
 
RxJava on Android
RxJava on AndroidRxJava on Android
RxJava on Android
 
operating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdfoperating system ubuntu,linux,MacProgram will work only if you g.pdf
operating system ubuntu,linux,MacProgram will work only if you g.pdf
 
ARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lectureARM 7 LPC 2148 lecture
ARM 7 LPC 2148 lecture
 

Kürzlich hochgeladen

Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
chumtiyababu
 

Kürzlich hochgeladen (20)

School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
Engineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planesEngineering Drawing focus on projection of planes
Engineering Drawing focus on projection of planes
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
NO1 Top No1 Amil Baba In Azad Kashmir, Kashmir Black Magic Specialist Expert ...
 
Moment Distribution Method For Btech Civil
Moment Distribution Method For Btech CivilMoment Distribution Method For Btech Civil
Moment Distribution Method For Btech Civil
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLEGEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
GEAR TRAIN- BASIC CONCEPTS AND WORKING PRINCIPLE
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
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()
  • 6. { clock_t d; d = clock(); while(1){ task1(2,2); task3(4,5); task2(2,2); delaySlackTime(200); task1(2,2); delaySlackTime(1000); task4(6,6); task2(2,2); task1(2,2); delaySlackTime(1000); task2(2,2); task1(2,2); delaySlackTime(1200); task1(2,2); delaySlackTime(1000); task2(2,2); delaySlackTime(200);
  • 7. d = clock() -d; double time_taken = ((double)d)/CLOCKS_PER_SEC; printf("total time taken = %.2f sn", time_taken); } }
  • 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.