Hi Murat, Please first try Ipc_pingpong example . this will create 2 thread message is transfer from one to another.
when RIOT initially starts up, the CPU is normally running in interrupt mode (using the interrupt mode stack). After creating the stacks for the main and the idle threads, the CPU must be put into thread-mode. This means the main threads initial context needs to put into the CPUs registers and the stack pointer must put to the main-threads stack. After this is done the CPU can just do 'normal' task switching for switching between threads. So to put it short: in cpu_switch_context_exit() you simply must load the main threads context into the CPUs register and point the stack pointer to the main threads stack. Thanks Shishir tiwari On Tue, Feb 10, 2015 at 12:03 AM, Murat CAKMAK <[email protected]> wrote: > Thanks Kaspar, > > > > According to your explanations (Interrupting with ISR or higher priority), > RIOT works like as a single thread application. > > > > I would expect a context switch mechanism for a quantum value even if > threads have same priority. > > > > I have tried vtimer_usleep() method instead of my delay() function in two > thread. > > static void *led3Thread(void *arg) > > { > > while (1) > > { > > LED3_Write(!LED3_Read()); > > vtimer_usleep(n); // Tried with 500000, 1000000 > > } > > } > > > > static void *led4Thread(void *arg) > > { > > while (1) > > { > > LED4_Write(!LED4_Read()); > > vtimer_usleep(n); // Tried with 500000, 1000000 > > } > > } > > > > After first call of vtimer_usleep(), execution is blocking (no changes on > leds) in vtimer_usleep() function. > > For a single thread vtimer_usleep() function is working well. > > > > FYI. > > > > Murat. > > > > -----Original Message----- > > From: devel [mailto:[email protected]] On Behalf Of Kaspar Schleiser > > Sent: Monday, February 9, 2015 8:02 PM > > To: [email protected] > > Subject: Re: [riot-devel] Context Switching > > > > Hi Murat, > > > > On 02/09/15 18:46, Murat CAKMAK wrote: > >> Threads looks like working as blocking. In general, led3Thread is > >> started before and only led3Thread is working. Never switch to > >> Led4Thread (I could not see changes on Led4). > >> > >> If I dont create thread3, I can see changes on Led4. > >> > >> So, Why am I not able to observe context switching? Is it normal > >> behaviour or not? > > > > RIOT will only interrupt a running thread if an ISR occurs or a higher > priority thread becomes runnable. So what you see is expected behaviour. > > > > Using vtimer_usleep should put the calling thread to sleep (if the delay is > high enough to not cause spin-locking). Could you try that with a fairly > high sleep time (e.g., a second)? > > > > Kaspar > > _______________________________________________ > > devel mailing list > > [email protected] > > http://lists.riot-os.org/mailman/listinfo/devel > > > _______________________________________________ > devel mailing list > [email protected] > http://lists.riot-os.org/mailman/listinfo/devel > _______________________________________________ devel mailing list [email protected] http://lists.riot-os.org/mailman/listinfo/devel
