NEWAthulya Experiment 1,2,3,4 Rtos
NEWAthulya Experiment 1,2,3,4 Rtos
Department
of
Multidisciplinary Engineering
Branch EECE
Section A
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
Experiment No.- 1 21ecu008
Theory/Commands/Circuit diagram:
Step 1 - Installation
Requirements:
1. Development board (e.g., STM32, Arduino, Raspberry Pi, etc.).
2. Computer with internet access.
3. Appropriate development environment (e.g., Eclipse, Visual Studio Code, etc.).
4. USB cable for programming the development board.
Steps:
1. Download Free RTOS:
- Visit the official Free RTOS website: [https://www.freertos.org/]
(https://www.freertos.org/)
- Navigate to the "Quick Start Guide" or "Downloads" section.
- Download the Free RTOS source code or pre-built binaries suitable for your development
board.
Conclusion:
The experiment aims to successfully download, install, and run FreeRTOS on a development
board. Through this process, you gain hands-on experience with real-time operating systems
and can explore building more complex applications using FreeRTOS.
Experiment No.- 2 21ecu008
CODE :
void setup()
{
Serial.begin(9600); // Enable serial communication.
pinMode(4, OUTPUT); // define LED1 pin as a digital output
pinMode(5, OUTPUT); // define LED2 pin as a digital output
//Create the first task at priority 1
// Name of task is "LED1"
// Stack size is set to 100
// we do not pass any value to Task1. Hence, third agument is NULL
// Set the priority of task to one
// Task1 handler is not used. Therefore set to Null
xTaskCreate(Task1, "LED1", 100, NULL, 1, NULL); // xtaskcreate is used to create a fresh
task
// Start FreeRTOS scheduler in Preemptive timing silicing mode
vTaskStartScheduler(); // starts real time kernel
}
void loop()
{
// Do nothing as schduler will allocated CPU to Task1 and Task2 automatically
}
/* Task1 with priority 1 */
void Task1(void* pvParameters) // void* means we are pointing to an unknown type of data
{
while(1)
{
Serial.println("Task1 Running"); // print "Task1 Running" on Arduino Serial Monitor
digitalWrite(4, HIGH); // sets the digital pin 4 on
digitalWrite(5, LOW); // sets the digital pin 5 off
xTaskCreate(Task2, "LED2", 100, NULL, 2, &TaskHandle_2); // create task2 with priority
2
vTaskDelay( 100 / portTICK_PERIOD_MS ); // create delay between tasks, here wait for
one second
}
}
/* Task2 with priority 2 */
void Task2(void* pvParameters)
{
//digitalWrite(5, HIGH); // sets the digital pin 5 high
//digitalWrite(4, LOW); // sets the digital pin 4 low
Serial.println("Task2 is runnig and about to delete itself");
vTaskDelete(TaskHandle_2); //Delete own task by passing NULL(TaskHandle_2 can also
be used)
}
OUTPUT :
Experiment No.- 3 21ecu008
CODE :
1. Calculator in C
#include <stdio.h>
int main() {
int num1, num2;
float answer;
char oper;
printf("Enter an operator (+, -, *, /): ");
scanf("%c", &oper);
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
if (oper == '+') {
answer = num1 + num2;
printf("%d + %d = %.2f", num1, num2, answer);
}
else if (oper == '-') {
answer = num1 - num2;
printf("%d - %d = %.2f", num1, num2, answer);
}
else if (oper == '*') {
answer = num1 * num2;
printf("%d * %d = %.2f", num1, num2, answer);
}
else if (oper == '/') {
if (num2 != 0) {
answer = (float)num1 / num2;
printf("%d / %d = %.2f", num1, num2, answer);
} else {
printf("Error! Division by zero."); return 1;
}
}else {
printf("Error! Invalid operator.");
return 1;
}return 0;
}
OUTPUT :
#include <stdio.h>
#include <string.h>
int main()
{
char str[] = { "naman" };
int l = 0;
int h = strlen(str) - 1;
while (h > l) {
if (str[l++] != str[h--]) {
printf("%s is not a palindrome\n", str);
return 0;
}
}
return 0;
}
OUTPUT :
#include <stdio.h>
int main()
{
CODE :
#include<stdio.h>
int main()
{
findavgTime(processes, n, burst_time);
return 0;
}
OUTPUT :