0% found this document useful (0 votes)
40 views

Rtos Exp3

The document discusses task management and scheduling using the Micrium real-time operating system. It describes creating tasks to perform basic math operations like addition, subtraction, multiplication and division, and using the scheduler to switch between the tasks.

Uploaded by

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

Rtos Exp3

The document discusses task management and scheduling using the Micrium real-time operating system. It describes creating tasks to perform basic math operations like addition, subtraction, multiplication and division, and using the scheduler to switch between the tasks.

Uploaded by

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

EX.

NO:3
TASK MANAGEMENT AND SCHEDULING USING
08.03.2024 OPEN-SOURCE REAL -TIME KERNEL (MICRIUM OS)

3.1 . AIM:

To understand how to develop an application that utilizes the concept of task


management and task scheduling with the help of scheduler in Micrium operating system.

3.2. TOOL REQUIRED:

● Text Editor (Notepad)

● DOS Box

● Micrium OS

● BC45 Borland C/C++ compiler

3.3 DESCRIPTION:

MICRIUM OS:

Micrium OS is a scalable, ROMable, pre-emptive real-time kernel that manages an


unlimited number of tasks. Micrium is a third-generation kernel and offers all of the services
to a modern real-time kernel, such as resource management, synchronization, inter-task
communications, and more. However, Micrium offers many unique features not found in other
real-time kernels, such as the ability to complete performance measurements at run-time, to
directly signal or send messages to tasks, achieve pending on multiple kernel objects, and more.
Micrium OS supports a nearly unlimited number of priority levels and provides features to
allow stack growth of tasks to be monitored. The execution time for most services provided by
Micrium OS is both constant and deterministic, as execution times do not depend on the
number of tasks running in the application.

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.

21EE61 REAL-TIME SYSTEMS LABORATORY 36


Micrium OS Real-Time Operating System supports ARM7, ARM9, Cortex-MX, Nios-
II, PowerPC, Coldfir, i.MX, Microblaze, RX600, H8, SH, M16C, M32C, Blackfin, and more.

• Reliable – Micrium software includes comprehensive documentation, full


source code, powerful debugging features, and support for a huge range of CPU
architectures.
• Efficient – Micrium software offers unprecedented ease-of-use, a small
memory footprint, remarkable energy efficiency, and all with a full suite of
protocol stacks.
• Trusted - Engineers across the world building industrial controls, medical
devices, and aerospace systems know they can rely on Micrium software for the
foundation of exceptional products.

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.

21EE61 REAL-TIME SYSTEMS LABORATORY 37


Some of the examples of embedded systems are listed below:

1) Aerospace:

● Flight management systems

● Jet engine controls

● Weapons systems

● Guided and Unguided missiles

2) Audio:

● MP3 players

● Amplifiers and tuners

3) Automotive:

● Antilock braking systems

● Climate control air conditioning system

● Engine Management System

● Navigation system (GPS)

4) Communications:

● Routers

● Switches

● Cell phones

5) Computer Peripherals:

● Printers

● Scanners
6) Domestic:

● Air conditioners

● Thermostats

● White goods

21EE61 REAL-TIME SYSTEMS LABORATORY 38


7) Workplace automation:

● Fax machines / Copiers

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.

DOS is a GUI type of Operating System. DOSBox is a command-line program,


configured by a set of command-line arguments. DOS is a single-tasking, single-user operating
system with a command-line interface. DOS acts on commands.To understand this experiment
printing of various mathematical operations like addition, subtraction, multiplication, division
as individual tasksare chosen as an application which utilizes Micrium OS entities like task
scheduler to schedule tasks basically referred as inter process communication.

21EE61 REAL-TIME SYSTEMS LABORATORY 39


3.4 PROGRAM FILES:

#include "includes.h"

#define TASK_STK_SIZE 2048

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

void Task1(void *data);

void Task2(void *data);

void Task3(void *data);

void Task4(void *data);

void Task5(void *data);

void Task6(void *data);

float a,b,c

void main (void)

{ OSInit();

PC_VectSet(uCOS,OSCtxSw);

OSTaskCreate(Task1,(void

*)0,&Task1Stk[TASK_STK_SIZE - 1],11);

OSTaskCreate(Task2,(void *)1,&Task2Stk[TASK_STK_SIZE - 1],12);

21EE61 REAL-TIME SYSTEMS LABORATORY 40


OSTaskCreate(Task3,(void *)2,&Task3Stk[TASK_STK_SIZE - 1],13);

OSTaskCreate(Task4,(void *)3,&Task4Stk[TASK_STK_SIZE - 1],14);

OSTaskCreate(Task5,(void *)4,&Task5Stk[TASK_STK_SIZE - 1],15);

OSTaskCreate(Task6,(void *)5,&Task6Stk[TASK_STK_SIZE - 1],16);

OSStart(); }

void Task1 (void *pdata)

{ INT8U err;

pdata=pdata;

for(;;)

{printf("\nTASK 1 is running...");

printf("\nEnter two numbers:");

scanf("%f%f",&a,&b);

printf("\nTASK 1 Suspends itself..");

OSTaskSuspend(OS_PRIO_SELF);

}}

void Task2 (void *pdata)

{ INT8U err;

pdata=pdata;

for(;;)

{ printf("\nTASK 2 is executing...");

printf("\nAddition:");

c=a+b;

21EE61 REAL-TIME SYSTEMS LABORATORY 41


printf("\n\t\tSum=%f",c);

printf("\nTASK 2 Suspends itself...");

OSTaskSuspend(OS_PRIO_SELF);

}}

void Task3 (void *pdata)

{ 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);

21EE61 REAL-TIME SYSTEMS LABORATORY 42


printf("\nTASK 4 Suspends itself.");

OSTaskSuspend(OS_PRIO_SELF);

} }void Task5 (void *pdata)

{ INT8U err;

pdata=pdata;

for (;;)

{printf("\nTASK 5 is running...");

printf("\nDivision:");

c=a/b;

printf("\n\t\tDiv=%f",c);

printf("\nTASK 5 Suspends itself.");

OSTaskSuspend(OS_PRIO_SELF);

} }void Task6 (void *pdata)

{ INT8U err;

pdata=pdata

for (;;){printf("\nTASK 6 is running...");

printf("\nResuming all other tasks...");

OSTaskResume(11);

OSTaskResume(12);

OSTaskResume(13);

OSTaskResume(14);

OSTaskResume(15); } }

21EE61 REAL-TIME SYSTEMS LABORATORY 43


EXPLANATION:

• 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.

21EE61 REAL-TIME SYSTEMS LABORATORY 44


3.5 PROCEDURE:

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

Fig 3.1: Compiling the make-file

Figure 3.1 explains the first four steps mentioned above such as mounting micrium OS
locally and to execute the makefile created.

21EE61 REAL-TIME SYSTEMS LABORATORY 45


3.6 OUTPUT:

Fig 3.2: Running the application

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.

Fig 3.3: Final output

21EE61 REAL-TIME SYSTEMS LABORATORY 46


The output screenshot figure 3.3 shows the final output which prints the mathematical
operations by utilizing the task scheduler of Micrium OS and DOS box is given below.

Here 6 tasks are implemented:

● Task 1 is to get inputs from the user for which the mathematical operations will be
performed.

● Task 2 is to perform addition operation.

● Task 3 is to perform subtraction operation.

● Task 4 is to perform multiplication operation.

● Task 5 is to perform division operation.

● 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:

The concept of task management and task scheduling is successfully implemented by


using scheduler available in Micrium OS and the DOS Box software along with this the outputs
for this experiment were also observed.

21EE61 REAL-TIME SYSTEMS LABORATORY 47

You might also like