/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / Upgrading an existing mono task circle Os

Username:     
Password:     
             

Forum
  • Index
  •  » circleOS
  •  » Upgrading an existing mono task circle Os

# 1   2010-04-14 19:25:34 Upgrading an existing mono task circle Os

ali_zarrouk
New member
From: Tunisia
Registered: 2010-02-16
Posts: 8

Upgrading an existing mono task circle Os

Hi ,

I'm working on a project on one of the STM32 MCUs wich OS is mono task and I need to get multi task real time , it's the v 3.8 of circle OS.

I have to make a scheduler with a Round Robin strategy and a dispatcher.

What I want to do is to add a function to those executed in the systick handler , the functions that "refreshes" hardware let's say , this function will be the scheduler wich will commute between 4 tasks in RAM every quantum time and execute the dispatcher in the PendSV exception handler generated by the scheduler .

It seems theoritcally simple , but I'd like to know if there are more things to handle to get this task done. Is there more files I need I need to handle than those where the PendSV handler is written and the one where I'll write the scheduler ?

An other thing , after the wfi executed ( after initializing) , is there something showing what code will be executed before executing the handler of that interrupt ?
The code meaning the functions of the NVIC wich will enable , active or pend en exception.

Offline

 

# 2   2010-04-15 07:50:06 Upgrading an existing mono task circle Os

Francis
Administrator
From: France-Grenoble
Registered: 2007-07-09
Posts: 890

Re: Upgrading an existing mono task circle Os

We are also thinking about improving CircleOS, by adding multi-tasing support. But it will not be available before several months...
About your description: one of the most important action - seems not to be in your description- is switching the stacks reserved for each task.

Offline

 

# 3   2010-04-15 08:17:00 Upgrading an existing mono task circle Os

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Upgrading an existing mono task circle Os

There is more complicated issue with multitasking - virtual memory. Different tasks with separate memory need a memory redirection. Usualy this is solved by MMU, but STM32F doesn't have one. It's still posble if:
1) all applications are aware of memory used by another app. This is the most common case in other RTOS, where the whole software is written and compiled at once. In CircleOS you can add and remove apps. This is also the case for app with multiple execution threads.
2) all concurent apps are using only local variables so stack switching is enough.
3) debug watchpoint on lower part of ram used to replace address. I'm not sure if this is posible.

Offline

 

# 4   2010-04-21 16:24:45 Upgrading an existing mono task circle Os

ali_zarrouk
New member
From: Tunisia
Registered: 2010-02-16
Posts: 8

Re: Upgrading an existing mono task circle Os

Thanks a lot for answering me

Francis there will be a stack containing registers status for each task in the file that will contain the scheduler. Each time the app creates a task , the function that handles task_creation will add a stack of that task to the stack_list of the scheduler-dispacher space .
So I'll need to have the two libraries ( scheduling-dispatching and multi-tasking) share the same variables.

What I don't get is how I can have the adress of the first instruction of the starting routine
associated to a task , would you help me please ?

ntrf.zns , will I need to implement some mechanism handling virtual memory ?
If my app creates 4 or 5 tasks ( I'll test a producer - consumer app ) , would I need virtualisation , RAM will not be enough ?

Offline

 

# 5   2010-04-22 06:43:08 Upgrading an existing mono task circle Os

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Upgrading an existing mono task circle Os

It depends on the amount of concurency you need. If you want several applications running in CircleOS at once (like in any PC multitasking OS) without any interference to each other - you need virtual memory. If you're making a signgle application without installable services and plug-ins, you don't need it. Virtual memory is primarily required for multitasking OS with several apps from different vendors. So if you want to modify CircleOS so it will be able to run several existing applications i advise you to stop trying - it's almost imposible.

All existing RTOS a saw used to buid a single application with single address space. It more like "multi-threading" rather then "multi-tasking". You can duplicate their functionality in single app scale.

Offline

 

# 6   2010-04-22 07:28:36 Upgrading an existing mono task circle Os

ali_zarrouk
New member
From: Tunisia
Registered: 2010-02-16
Posts: 8

Re: Upgrading an existing mono task circle Os

Yes as you said , it will be multi threading rather than multi tasking , one single app creating some threads .
You talked about developping the functionalities in a single application scale ... Do you mean making the mult threading made by the application ? not a system library ?

I'm trying to implement pthread.h , I created a queue associated to each synchro tool , and some mechanism to check the state of the synchro variables created every time systick interrupt is generated

A question , do you know how much time takes an instruction , maximum time of an assembley instruct , I need it for the Round Robin

( Something I omitted to say , I'm a Newbie in Circle OS smile )

Offline

 

# 7   2010-04-22 08:12:43 Upgrading an existing mono task circle Os

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Upgrading an existing mono task circle Os

An example: if you want MP3Play application to work with Sol8Air game at the same time on the same Primer2, you need virtual memory. Why? Because they occupy the same space in RAM. For inter-application multi-threading you already have RAM split among all C/C++ global variables.

On ARM Cortex-M3 instruction timing is not constant. Some instructions can be "pipelined" so they executinig faster in some conditions. Instruction timing also depends on flash wait cycles and cache management. Why you need it for round-robin? It surpose to be time-based scheduler as far as i understand.

Read Cortex-M3 Technical reference manual. There you can find instrunction timings and guide for implementing milti-threading.

Offline

 

# 8   2010-04-22 16:48:46 Upgrading an existing mono task circle Os

ali_zarrouk
New member
From: Tunisia
Registered: 2010-02-16
Posts: 8

Re: Upgrading an existing mono task circle Os

Thanks for the info , I saw the Cortex-M3 technical reference manual and I saw the chapter about instruction timing

I need it for the quantum of round-robin , If I know how much cycles takes the max instruct , I can let's say fix the quantum to make sure that every task executes not all of its code and time is lost doing nothing.

Unfortunately I didn't found something that would help me implementing multi-threading .

Do you know how I can find the adress of the first instruct of a routine ? ( setting the PC of the task created )

Can I send you what I wrote , it's pretty clear and commented and you tell me what you think ?

Offline

 

# 9   2010-04-22 18:58:05 Upgrading an existing mono task circle Os

ntrf.zns
Member
From: Belgorod, Russia
Registered: 2009-11-01
Posts: 134

Re: Upgrading an existing mono task circle Os

Dual stack and it's switching described in Exceptions chapter (see 5.4 and 5.11).

When you creating a thread you're passing function pointer as a thread entry point. Use it as to set PC.

Offline

 

# 10   2010-04-24 17:30:50 Upgrading an existing mono task circle Os

ali_zarrouk
New member
From: Tunisia
Registered: 2010-02-16
Posts: 8

Re: Upgrading an existing mono task circle Os

Thank you very much

Offline

 

  • Index
  •  » circleOS
  •  » Upgrading an existing mono task circle Os

Board footer