0% found this document useful (0 votes)
48 views11 pages

NEWAthulya Experiment 1,2,3,4 Rtos

The document is a lab workbook for experiments on real-time operating systems (RTOS). It contains instructions for installing FreeRTOS and developing programs using different integrated development environments. The workbook includes examples of creating tasks in FreeRTOS and writing C programs for calculators, strings, arrays and implementing the first-come first-served scheduling algorithm.

Uploaded by

athulya21ecu008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views11 pages

NEWAthulya Experiment 1,2,3,4 Rtos

The document is a lab workbook for experiments on real-time operating systems (RTOS). It contains instructions for installing FreeRTOS and developing programs using different integrated development environments. The workbook includes examples of creating tasks in FreeRTOS and writing C programs for calculators, strings, arrays and implementing the first-come first-served scheduling algorithm.

Uploaded by

athulya21ecu008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

RTOS Lab Workbook

Real Time Operating System(RTOS)


Lab Work Book
Dr. Anu Tonk

School of Engineering & Technology

Department
of
Multidisciplinary Engineering

Name Athulya Gopal

Roll No. 21ECU008

Branch EECE

Section A

The NorthCap University


Gurugram, Haryana
INDEX Student Name: Athulya Gopal Roll No: 21ECU008

S. Name of Experiment Date of Total Faculty’s


No. Performance Marks Signature
(In the sequence of performance) with Date
(10)
1. Installing Arduino IDE and installing free 2/02/2024
RTOS library

2.

3.

4.

5.

6.

7.

8.

9.

10.

11.
Experiment No.- 1 21ecu008

Aim: Introduction to Free RTOS and setting up of different


IDEs

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.

2. Extract the Free RTOS files:


- If you downloaded the source code, extract the files to a suitable location on your
computer.

3. Set up the Development Environment:


- Install the required toolchain and development environment based on your development
board and Free RTOS port.
- Refer to the Free RTOS documentation for specific instructions on setting up the
development environment.

4. Configure Free RTOS:


- Navigate to the Free RTOS source code directory.
- Modify the configuration files according to your requirements (e.g., `FreeRTOSConfig.h`).

5. Run a Simple Example:


- Create a new project or use an existing example provided by Free RTOS.
- Implement a simple Free RTOS task for example program.
- Build and flash the program onto the development board.

6. Documentation and Feedback:


- Document the steps taken, and any issues encountered during the installation process.
- Provide feedback to the Free RTOS community if necessary.

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

OBJECTIVE : Create and delete a task in FreeRTOS and Arduino/Visual


Studio/Eclipse-based IDE.

SOFTWARE : Arduino IDE

CODE :

#include <Arduino_FreeRTOS.h> // include the free rtos library


#include "task.h" // include task.h(a library for handling tasks)
TaskHandle_t TaskHandle_2; // handler for Task2

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

OBJECTIVE : Creating C programs

SOFTWARE : Dev C++

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 :

2. Check whether the entered string is palindrome or not?

#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;

}
}

printf("%s is a palindrome\n", str);

return 0;
}
OUTPUT :

3. Find the largest number in a array.

#include <stdio.h>

int main()
{

int arr[] = {25, 11, 7, 75, 56};

int length = sizeof(arr)/sizeof(arr[0]);

int max = arr[0];

for (int i = 0; i < length; i++) {

if(arr[i] > max)


max = arr[i];
}
printf("Largest element present in given array: %d\n", max);
return 0;
}
Experiment No.- 4 21ecu008

OBJECTIVE : Creating a program in C to verify the FCFS algorithm.

SOFTWARE : Dev C++

CODE :

#include<stdio.h>

void findWaitingTime(int processes[], int n, int bt[], int wt[])


{
wt[0] = 0;

for (int i = 1; i < n ; i++ )


wt[i] = bt[i-1] + wt[i-1] ;
}

void findTurnAroundTime( int processes[], int n,


int bt[], int wt[], int tat[])
{

for (int i = 0; i < n ; i++)


tat[i] = bt[i] + wt[i];
}

void findavgTime( int processes[], int n, int bt[])


{
int wt[n], tat[n], total_wt = 0, total_tat = 0;

findWaitingTime(processes, n, bt, wt);

findTurnAroundTime(processes, n, bt, wt, tat);

printf("Processes Burst time Waiting time Turn around time\n");

for (int i=0; i<n; i++)


{
total_wt = total_wt + wt[i];
total_tat = total_tat + tat[i];
printf(" %d ",(i+1));
printf(" %d ", bt[i] );
printf(" %d",wt[i] );
printf(" %d\n",tat[i] );
}
float s=(float)total_wt / (float)n;
float t=(float)total_tat / (float)n;
printf("Average waiting time = %f",s);
printf("\n");
printf("Average turn around time = %f ",t);
}

int main()
{

int processes[] = { 1, 2, 3, 4, 5, 6};


int n = sizeof processes / sizeof processes[0];
int burst_time[] = {3, 2, 1, 4, 5, 2};

findavgTime(processes, n, burst_time);
return 0;
}

OUTPUT :

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy