Hi all
I need to implement Co-operative scheduling in micropython environment. I am new to Python(& micropython). I tried it by using "yield". But I couldn't understand it accordingly. Following is the example what I want and waht I am getting.
Suppose I have two tasks, and 7 instructions each task.
T1
loop forever:
{
T11:
T12:
T13:
T14:
T15: yield to Task T2
T16:
T17:
}
AND
T2
loop forever:
{
T21:
T22:
T23:
T24:
T25: Yield to Task T1.
T26:
T27:
}
If I start my execution from T1. The sequence of execution should be [T11, T12, T13, T14, T15, T21, T22, T23, T24, T25, T16, T17, T11, T12, T13, T14, T15, T26, T27, T21, T22, T23, T24, T25, T16, T17, T11, ........ ]
But I am getting sequence as [T11, T12, T13, T14, T15, T21, T22, T23, T24, T25, T11, T12, T13, T14, T15, T21, T22, T23, T24, T25, T11, T12, T13, T14, T15, T21, T22, T23, T24, T25, .....]
I am switching from one task to another by using "yield" keyword. yield pauses the current execution sequence and takes control to generator object(where I am switching between tasks)
If anyone can help me with correct way?
Implement co-operative schduling
-
- Posts: 288
- Joined: Sun May 04, 2014 8:54 am
Re: Implement co-operative schduling
We'd need the actual code to help.
Re: Implement co-operative schduling
When I use generator.next() in micropython It gives error "generator object has no attribute 'next' ".
I used it in Python without any library import it works. what can be the issue and solution?
I used it in Python without any library import it works. what can be the issue and solution?
Re: Implement co-operative schduling
tarun2121 wrote:When I use generator.next() in micropython It gives error "generator object has no attribute 'next' ".
I used it in Python without any library import it works. what can be the issue and solution?
Code: Select all
generator.next()
Code: Select all
next(generator)
Re: Implement co-operative schduling
Thanks.
It works.. !!
It works.. !!
Re: Implement co-operative schduling
Everything was already implemented, please see http://forum.micropython.org/viewtopic.php?f=3&t=85
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/