Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How does a multi-tasking kernel works?

Status
Not open for further replies.

StupidDum

New Member
Multi tasking is that microcontroller implementing several tasks at the same time. My knowledge on microprocessor (motorola 68000 series) is that the micro p fetch and decode instruction by instruction. So.. how does a new microprocessor works to carry out multitasking?
 
Basically they DON'T do multiple tasks at the same time, they switch rapidly between the different tasks, so run each task in turn. As this is done at high speed (hopefully) it gives the impression of doing them at the same time.

Interesting you mention the 68000, it was pretty good for multitasking, the old Commodore Amiga was far better at multi-tasking than any of the Intel based Microsoft machines.
 
As a demonstration, I have a piece of 68K and 6811 assembly that implements a very simple round robin scheduler for some products that I've designed. If there is some interest, I can post them ... I think they are each 10 or so lines of assembly.
 
crust said:
As a demonstration, I have a piece of 68K and 6811 assembly that implements a very simple round robin scheduler for some products that I've designed. If there is some interest, I can post them ... I think they are each 10 or so lines of assembly.

that would be great!
 
Multi tasking may be better than normal way ? I think, if there are two function, one running in 5ms and another running in 8ms, assum on one stick running in 1ms, it will be lost 16ms to complete two function. With normal way it just lost 13ms !
Is RTOS multi tasking OS ?
 
If you can do your tast just using interupts, its often faster, neater looking, and easyer to understand. But its often not possible to just do it all of ints.
 
StupidDum said:
crust said:
As a demonstration, I have a piece of 68K and 6811 assembly that implements a very simple round robin scheduler for some products that I've designed. If there is some interest, I can post them ... I think they are each 10 or so lines of assembly.

that would be great!

Code:
_scheduler_task_suspend:
   movem.l	a0-a6/d0-d7,-(a7)      ;* save the registers
   movea.l _thread_queue,a3      ;* get the current thread
   move.l  a7,stackp(a3)             ;* save the stack pointer
   movea.l nexttask(a3),a4         ;* save the next task in a4
   move.l #$0,nexttask(a3)         ;* null the next pointer 
                                              
   jmp skip_null		;* normally start next thread

;* unneeded code deleted

skip_null:
   move.w  pid(a4),d0		;* check if this is null task
   bne new_task		;* not the null task, so execute
   movea.l nexttask(a4),a4	;* load the next task (might be null)

new_task:
   move.l  a4,_thread_queue	;* set the current thread ptr
   move.l	stackp(a4),a7	;* restore the stack pointer
   movem.l	(a7)+,d0-d7/a0-a6	;* restore registers
   rte			;* kickstart new thread


It was 11 lines for the 68K, hope this helps ....
 
Status
Not open for further replies.

Latest threads

Back
Top