How to multitasking?

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi there,

Can anybody show me the way to learn about multitasking methods? I mean to give me advices about any sites, or books or anything else.
There is no need to based on an AVR program, I want just to read and learn about the method.
---------------------------------------
Thanks a lot, Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

Last Edited: Tue. Jan 27, 2015 - 07:19 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's an interesting article, if you don't want to go all out and do an RTOS, but still want to do some "multitasking":

http://www.embedded.com/2000/0009/0009feat4.htm

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's also a link on the Home page for an advanced article using an AVR.

Dave

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want a little more control than a super-loop, you may want to check out Brian Dean's bd-threads library. It's a straightforward real-time threading package that lets you control priority and scheduling of several threads at once. Moreover, it has a very small footprint. I've used it a couple of times with success.

link: http://www.bdmicro.com/code/thre...

-Bob

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks a lot, you were all of you very helpfull
-------------------------------------------------------
Thank you all, Michael

Michael.

User of:
IAR Embedded Workbench C/C++ Compiler
Altium Designer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is a very small and simple scheduler: but it shows cooperative multitasking for short tasks  and does not need any timer or assembler code.

 

 

void run( void (*funct_pt)(), unsigned long intervall)
{
  if (jobs==MAXJOBS) return;         
  func_array[jobs]=funct_pt;
  interv_array[jobs]=intervall;
  lastRun_array[jobs]=micros();
  jobs++;
}

 

 

void runner() {
  unsigned long m=micros();
  for (int i=0; i<jobs; i++) {
    // is it time for a task?
    if ((m - lastRun_array[i]) >= interv_array[i]) {
      funk_array[i]();  // YES, call function
      lastRun_array[i]=m;
    }
  }
}
    

 

void task1() {

...

}

 

void task2() {

...

}

 

void run (task1, 1000);

void run (task1, 1000);

while (1) runner();

Topic locked