Rtos Exp3
Rtos Exp3
NO:3
TASK MANAGEMENT AND SCHEDULING USING
08.03.2024 OPEN-SOURCE REAL -TIME KERNEL (MICRIUM OS)
3.1 . AIM:
● DOS Box
● Micrium OS
3.3 DESCRIPTION:
MICRIUM OS:
A kernel is a program or code which is the heart of the OS which provides vital task
scheduling and multi-tasking services to ensure that the timing requirements of the application
code is met, even when regularly updated and expanded code with new features. Micrium OS
is more than a kernel, but it also provides a number of additional modules.
Real-time systems are systems whereby the correctness of the computed values and
their timeliness are at the forefront. Real-time systems are typically more complicated to
design, debug, and deploy than non - real - time systems. A real-time kernel is software that
manages the time and resources. The design process of a real-time application involves splitting
the work into tasks, each responsible for a portion of the job. A task is a simple program that
thinks it has the Central Processing Unit completely to itself. On a single CPU, only one task
executes at any given time.
The kernel is responsible for the management of tasks. This is called multitasking.
Multitasking is the process of scheduling and switching the CPU between several tasks. The
CPU switches its attention between several sequential tasks. Multitasking provides the illusion
of having multiple CPUs and maximizes the use of the CPU. Multitasking also helps in the
creation of modular applications.
One of the most important aspects of multitasking is that it allows the application
programmer to manage the complexity inherent in real-time applications. Application
programs are easier to design and maintain when multitasking is used. Real-time applications
cover a wide range, but many real-time systems are embedded. An embedded system is a
computer built into a system and not acknowledged by the user as being a computer.
1) Aerospace:
● Weapons systems
2) Audio:
● MP3 players
3) Automotive:
4) Communications:
● Routers
● Switches
● Cell phones
5) Computer Peripherals:
● Printers
● Scanners
6) Domestic:
● Air conditioners
● Thermostats
● White goods
8) Process Control:
● Chemical Plants
● Factory automation
● Food processing
A Real Time Operating System generally contains a real-time kernel and other higher-
level services. Micriumoffers a complete suite of RTOS components including: μC/FS (an
Embedded File System), μC/TCP-IP (a TCP/IP stack), μC/GUI (a Graphical User Interface),
μC/USB (a USB device, host and OTG stack), and more. Most of these components are
designed to work standalone. In fact, users can pick and choose only the components required
for the application. Refer www.micrium.com website for further references.
DOS BOX:
DOSBox is a great piece of software that allows users to run a huge collection of very
old PC software dating back to the 1980s and 1990s on your Linux system. Versions for
Windows, MacOS, and others exist as well. DOSBox is a free and open-source emulator which
runs software for MS-DOS compatible disk operating systems. Micrium is a 16-bit operating
system whereas Windows and Linux are available in 32 bit and 64-bit architecture, we cannot
directly run Micrium OS in Windows or Linux, thus we use DOS Box to run Micrium OS in
Windows.
#include "includes.h"
OS_STK Task1Stk[TASK_STK_SIZE];
OS_STK Task2Stk[TASK_STK_SIZE];
OS_STK Task3Stk[TASK_STK_SIZE];
OS_STK Task4Stk[TASK_STK_SIZE];
OS_STK Task5Stk[TASK_STK_SIZE];
OS_STK Task6Stk[TASK_STK_SIZE];
float a,b,c
{ OSInit();
PC_VectSet(uCOS,OSCtxSw);
OSTaskCreate(Task1,(void
*)0,&Task1Stk[TASK_STK_SIZE - 1],11);
OSStart(); }
{ INT8U err;
pdata=pdata;
for(;;)
{printf("\nTASK 1 is running...");
scanf("%f%f",&a,&b);
OSTaskSuspend(OS_PRIO_SELF);
}}
{ INT8U err;
pdata=pdata;
for(;;)
{ printf("\nTASK 2 is executing...");
printf("\nAddition:");
c=a+b;
OSTaskSuspend(OS_PRIO_SELF);
}}
{ INT8U err;
pdata=pdata;
for (;;)
{printf("\nTASK 3 is running...");
printf("\nSubtraction:");
c=a-b;
printf("\n\t\tDifference=%f",c);
printf("\nTASK 3 Suspends itself...");
OSTaskSuspend(OS_PRIO_SELF);
}}
void Task4 (void *pdata)
{ INT8U err;
pdata=pdata;
for (;;)
{printf("\nTASK 4 is running...");
printf("\nMultiplication:");
c=a*b;
printf("\n\t\tMulti=%f",c);
OSTaskSuspend(OS_PRIO_SELF);
{ INT8U err;
pdata=pdata;
for (;;)
{printf("\nTASK 5 is running...");
printf("\nDivision:");
c=a/b;
printf("\n\t\tDiv=%f",c);
OSTaskSuspend(OS_PRIO_SELF);
{ INT8U err;
pdata=pdata
OSTaskResume(11);
OSTaskResume(12);
OSTaskResume(13);
OSTaskResume(14);
OSTaskResume(15); } }
• Header Inclusion and Definitions: The code begins with including necessary
headers (includes.h) and defines TASK_STK_SIZE to specify the size of the task
stacks.
• Global Variables: Three global variables a, b, and c are declared, presumably to
hold numerical values.
• Task Function Declarations: Task functions Task1() through Task6() are declared.
These functions represent different tasks that will be executed concurrently.
• Main Function: The main() function initializes the uC/OS with OSInit() and sets
up the context switch vector. Tasks are created using OSTaskCreate(), each with its
own priority.
• Task Functions: Each task function represents a separate task that will be executed
concurrently.
• Each task function contains an infinite loop (for(;;)) representing continuous
execution.
o Task1() reads two numbers from the user, suspends itself, and stores the
numbers in global variables a and b.
o Task2() computes the sum of a and b and prints it.
o Task3() computes the difference of a and b and prints it.
o Task4() computes the product of a and b and prints it.
o Task5() computes the division of a by b and prints it.
o Task6() continuously runs and resumes all other tasks.
• Task Suspension and Resumption: Tasks suspend themselves using
OSTaskSuspend(OS_PRIO_SELF) after completing their operations. This means
they voluntarily give up the processor until they are resumed. Task6() resumes tasks
with priorities 11 through 15 using OSTaskResume().
• RTOS Concepts: The code demonstrates concepts of real-time operating systems
(RTOS) such as task creation, suspension, resumption, and task priorities.
Overall, this code implements a simple multi-tasking system using the uC/OS real-
time operating system, where multiple tasks execute concurrently, performing different
mathematical operations on user-provided numbers.
Some steps need to be followed in DOS Box before running the application.
Step 1 - Open the DOS Box mount the local directory where the micrium OS folder is
located with the E directory by using the command E local directory name:\Micrium. For
example, in this experiment the local directory used is E. therefore the command for
mounting will be
Mount E E:\Micirum
Step 2 – Change the directory from F to E drive by typing E: command in the DOS
Box command prompt.
E:
Step 3 – In order to obtain the latest executable file for the developed application in an
effective way navigate to the location where make utility software is located by using the
command cd EXPS\EX1\TEST and click enter. This command is not unique it varies based
on the make utility software location.
cd EXPS\EX1\TEST
Step 4 – Now provide the make file written for the application to the make utility
software by using the command maketest -f makefile name with extension for this
application use the command maketest -f test.mak. Once this is done the executable file is
generated and by simply typing the name of the application you can run the application.
maketest -f test.mak
Figure 3.1 explains the first four steps mentioned above such as mounting micrium OS
locally and to execute the makefile created.
Figure 3.2 shows the processes carried out using makefile such as copying the needed
link files, header file to local directory and creation of the object file for execution.
● Task 1 is to get inputs from the user for which the mathematical operations will be
performed.
● Task 6 is to resume all these tasks (1-5) to continue the same steps again by using the
command os_resume(task_id).
3.7 INFERENCE:
From this experiment, the use of scheduler for scheduling the task set based on our
application is inferred and the temporary mounting of directories in DOS Box is also been
understood and finally the use age of make utility software on Micrium OS is also studied by
using bc45 Borland C/C++ compiler.
3.8 RESULT: