Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

real time operating system program?

Status
Not open for further replies.

vead

Full Member level 5
Joined
Nov 27, 2011
Messages
285
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Activity points
3,815
real time operating system program ?

Hello
actually I am searching whole program for RTOS written in c . But I am not getting suitable example. does anyone have RTOS code or link which show part of kernel and scheduling. If yas than please post here.
 

Re: real time operating system program ?

have you gone through FreeRTOS?
 

Re: real time operating system program ?

have you gone through FreeRTOS?

yas I have downloaded sample project

here is one example code but I don't understand which part of code is kernel
Code:
/* FreeRTOS.org includes. */
#include "FreeRTOS.h"
#include "task.h"

/* Demo includes. */
#include "supporting_functions.h"

/* Used as a loop counter to create a very crude delay. */
#define mainDELAY_LOOP_COUNT		( 0xffffff )

/* The task function. */
void vTaskFunction( void *pvParameters );

/* Define the strings that will be passed in as the task parameters.  These are
defined const and off the stack to ensure they remain valid when the tasks are
executing. */
const char *pcTextForTask1 = "Task 1 is running\r\n";
const char *pcTextForTask2 = "Task 2 is running\r\n";

/*-----------------------------------------------------------*/

int main( void )
{
	/* Create the first task at priority 1... */
	xTaskCreate( vTaskFunction, "Task 1", 1000, (void*)pcTextForTask1, 1, NULL );

	/* ... and the second task at priority 2.  The priority is the second to
	last parameter. */
	xTaskCreate( vTaskFunction, "Task 2", 1000, (void*)pcTextForTask2, 2, NULL );

	/* Start the scheduler to start the tasks executing. */
	vTaskStartScheduler();	

	/* The following line should never be reached because vTaskStartScheduler() 
	will only return if there was not enough FreeRTOS heap memory available to
	create the Idle and (if configured) Timer tasks.  Heap management, and
	techniques for trapping heap exhaustion, are described in the book text. */
	for( ;; );
	return 0;
}
/*-----------------------------------------------------------*/

void vTaskFunction( void *pvParameters )
{
char *pcTaskName;
volatile uint32_t ul;

	/* The string to print out is passed in via the parameter.  Cast this to a
	character pointer. */
	pcTaskName = ( char * ) pvParameters;

	/* As per most tasks, this task is implemented in an infinite loop. */
	for( ;; )
	{
		/* Print out the name of this task. */
		vPrintString( pcTaskName );

		/* Delay for a period. */
		for( ul = 0; ul < mainDELAY_LOOP_COUNT; ul++ )
		{
			/* This loop is just a very crude delay implementation.  There is
			nothing to do in here.  Later exercises will replace this crude
			loop with a proper delay/sleep function. */
		}
	}
}
 

Re: real time operating system program ?

The kernel is in FreeRTOS source which you are calling with FreeRTOS.h.
As a user you are creating the tasks specific to application with the help of task.h
 

Re: real time operating system program ?

Hello srizbf

Thanks for helping me. can you help me with example ?
 

Re: real time operating system program ?

Any program. Any. It's that simple.

Generally there is no such thing as an RTOS "program", as there would traditionally be. In an RTOS, you have threads, which execute and perform ASIC functionality. OTOH, any "program" can be run in an RTOS, provided the libraries and hardware exist to satisfy that particular program's needs.

Now what RTOS's differ from traditional OS's is in two things:
1) scheduling,
2) hardware access,
3) customization specific to the ASIC it is running on.

Scheduling is real-time, meaning everything executes in real-time, so it is not a general purpose scheduler kernel. This cannot be stressed enough. Also a well-written RTOS would include utilities like semaphores, spinlocks, request-to-schedule functions, creating and destroying threads, and so on.
Secondly, hardware access is direct, usually though a single level HAL, to make operation fast.
Thirdly, customization is very important depending on the processor selected, the memory, busses, ASIC behavior, etc. There is no single silver-bullet.

Generally, code for a well-written preemptive RTOS shouldn't be much different than that of a regular UNIX-like OS. Remember it's the kernel which does the magic under the hood.

You're better off learning Linux inside-out, multi-threading, spinlocks; then applying this knowledge to a specific RTOS you're working on.
 

Re: real time operating system program ?

So RTOS are a pretty different from your usual OS (Linux, Windows, etc). They are real-time and usually preemptive. This changes how they work considerably. Most of the time the kernel is really small and simple to facilitate those two functions. Multi-threaded processor support may complicate this a little. (RTOS implementation details.)

If my understanding of FreeRTOS is correct there is not really a kernel but rather a scheduler. Each process is a task which is given execute according to priority of scheduler. Each task has a priority and a state of execution. Using this the scheduler determines which task should run next at the end of a time slice. If need be it will suspend a task and load another one. So in the code you posted you can see the creation of the task, size of the task, and priority of the task. The freeRTOS does do memory management, but I forget the details of this. FreeRTOS also allows task to block on timers and message queues.

More than likely you will need to create tasks for managing the hardware. So like if you have an SD card, you would build a task for it. Any other task that wants to talk to the SD card would send a message to that task via a message queue. The SD card task would block till a message came in an it was allowed to run due to priority. You have access to most of the hardware. You build what you need.

Does this sound a little familiar to something like bare-metal programming? Well in many ways that is kind of what your doing, but in a generic sense. So the RTOS provides you an interface to standardize the prioritization of important tasks in a more real time manner via the scheduler.

The scheduler is the difference here! Also I would be surprised if you will see a lot of hardware management in a RTOS kernel, but I could be wrong.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top