Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in ‘pico_protocol_generic_loop’ #482

Open
StupidZJF opened this issue Mar 9, 2018 · 3 comments
Open

Problem in ‘pico_protocol_generic_loop’ #482

StupidZJF opened this issue Mar 9, 2018 · 3 comments

Comments

@StupidZJF
Copy link

I read the source code of picotcp, and I have some questions.
First, what is the ‘pico_protocol_generic_loop’ function purpose? What is in the loop? The protocol or the layer?
Second, Whether the project is multi-threading, if so, where does the code create the new thread? if not , how does the function 'pico_stack_tick' to assign CPU time slices to all the modules previously registered

@danielinux
Copy link
Contributor

Hello,
the function you mention is used to loop across all the modules (i.e. each of the protocol) input and output functions, and this happens every time pico_stack_tick is called. This allows the packets to flow in both direction at every tick. In a bare-metal, single thread, pico_stack_tick should be called regularly from the main event loop.

The support for multithreaded environments works as follows:

  • PICO_SUPPORT_MUTEX must be enable, to ensure that the socket queues (which may be shared across threads) are protected, and you should provide the implementation of the mutex primitives (lock, unlock)
  • The OS should spawn a separate thread which calls pico_stack_tick at regular interval
  • Other threads can open sockets and call picotcp API

For examples of integration in RTOS see also:

@danielinux
Copy link
Contributor

More details on how to port on *OS in the wiki documentation:
https://github.com/tass-belgium/picotcp/wiki/Porting-picoTCP-OS

@StupidZJF
Copy link
Author

StupidZJF commented Mar 10, 2018

Thank you for your reply.
there is a question that does that means it is single thread if I do not call some additional thread function manually? So is it a event-trigger structure? So what does upper layer do while lower layer is processing the frame. For example, when ipv4 is processing a frame which sent by udp, what dose udp doing? Looping or waiting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants