- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Guys,
I've been working with the simple socket server example. One thing has been stumping me, i can't exactly see how the tasks relenquish control. The http://www.altera.com/literature/tt/tt_nios2_tcpip.pdf document outlines creation of Niche Stack specific tasks but doesn't clearly (for me) show about switching between. Basically i want to have a TCP server and client working simulataneously. What command do you guys recommend for these to relinquish control to each other? Thanks in AdvanceLink Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The scheduler is responsible for this. The one is ucOS is rather simple and just uses priorities. Just create two tasks, and when the one with the highest priority goes to sleep or waits on an I/O (including network), the one with the lower priority will run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply Diaxiwen.
Just to be clear. If each task is an infinite while loop. If i use should i use the "TKSleep(1)" function and the end of each tasks loop, the scheduler will rotate through the tasks automatically?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You really don't want to have tasks in infinite while loops on any scheduler (well any scheduler that uses a stack per task and allows tasks to sleep). Your tasks need to block somewhere and be woken up by an interrupt or other task when there is work to do.
There is a vague possibility that TKSleep(0) will cause a reschedule - but I've no idea really what that call does. In any case that will only work if your spinning tasks are the lowest priority ones (and the scheduler hasn't done anything silly like increase the priority to avoid a 'priority inversion' problem). For small embedded systems it isn't unusual to just call every 'task' in turn. If your code works this way you often don't need to take interrupts from many devices, since the main loop can directly check the device registers often enough. This saves the expence of the register saves required for the interrupt, and any requirement to mask the interrupt through 'critical sections'. Slightly larger systems (and even quite big systems) will use a very limited number of blockable system threads, using each to process a (dynamic) list of work functions (which must not block waiting external events).- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
With network server and client tasks you can probably use blocking calls and they will be put to sleep automatically when they have to wait for network traffic.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think Daixiwen is right. There must be network calls that do that since, i had some earlier experiment tasks i made and i'm pretty I didn't use any sleep and they worked. I'll give it a go.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page