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

Find a better naming for "MAIN"-constants #732

Closed
OlegHahm opened this issue Feb 18, 2014 · 6 comments
Closed

Find a better naming for "MAIN"-constants #732

OlegHahm opened this issue Feb 18, 2014 · 6 comments
Assignees
Labels
State: won't fix State: The issue can not or will not be fixed Type: question The issue poses a question regarding usage of RIOT

Comments

@OlegHahm
Copy link
Member

There are two constants in RIOT having a MAIN in their name, that are actually meant to be used not only for the main thread (as the name would suggest) but as standard case:

  • KERNEL_CONF_STACKSIZE_MAIN
  • PRIORITY_MAIN

In order to reflect the intension to use these variables as a default value I propose to add a constant PRIORITY_DEFAULT. However, for the stack size constant it's a bit more difficult, because we already have a KERNEL_CONF_STACKSIZE_DEFAULT which differs from KERNEL_CONF_STACKSIZE_MAIN by not offering enough stack for using printf(). So, in short I'm looking for a more self-explaining name for a constant set to (KERNEL_CONF_STACKSIZE_DEFAULT + KERNEL_CONF_STACKSIZE_PRINTF).

@OlegHahm OlegHahm added this to the Release NEXT MAJOR milestone Feb 18, 2014
@LudwigKnuepfer LudwigKnuepfer removed this from the Release 2014.05 milestone Apr 28, 2014
@Jentsch
Copy link

Jentsch commented Jun 2, 2014

Why not increment KERNEL_CONF_STACKSIZE_PRINTF by KERNEL_CONF_STACKSIZE_DEFAULT and drop the KERNEL_CONF_STACKSIZE_MAIN name?

@OlegHahm
Copy link
Member Author

OlegHahm commented Jun 2, 2014

Well, KERNEL_CONF_STACKSIZE_DEFAULT is the recommended stack size for a "normal" thread (not using printf). KERNEL_CONF_STACKSIZE_PRINTF is the additional stack size needed if the thread uses printf() (might be zero). Since the main thread always uses printf() KERNEL_CONF_STACKSIZE_MAIN is a sum of both. I would say, all three macros are needed.

@Jentsch
Copy link

Jentsch commented Jun 2, 2014

I would think currently …STACKSIZE_PRINT has no meaning for application developer.

Either I create a thread with printf, then I use …STACKSIZE_DEFAULT or I use printf and use …STACKSIZE_MAIN, but I would never use …STACKSIZE_PRINTF. It's only confusing to have such an option. (see this discussion)

May we should keep …STACKSIZE_PRINTF for internals (e.g. calculation of …STACKSIZE_MAIN) but hide it somehow from application developers.

@OlegHahm
Copy link
Member Author

OlegHahm commented Jun 2, 2014

What about this case: your application or library needs to spawn a thread and you know that it requires a stack either much smaller or much bigger than the default case. But this thread also calls printf() and you know that some platforms with shitty libcs (say newlibc) require additional stack for these calls.

Anyway, if I get you right you feel comfortable with KERNEL_CONF_STACKSIZE_DEFAULT and KERNEL_CONF_STACKSIZE_MAIN and are only confused about this PRINTF define?

@Jentsch
Copy link

Jentsch commented Jun 2, 2014

Let me rephrase it: my application needs printf and needs much more memory than usually. KERNEL_CONF_STACKSIZE_MAIN + X where X is the additional memory. Still no need for ...STACKSIZE_PRINTF.

@OlegHahm OlegHahm added this to the FIX ME FIRST milestone Jun 3, 2014
@OlegHahm
Copy link
Member Author

It seems no one has a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
State: won't fix State: The issue can not or will not be fixed Type: question The issue poses a question regarding usage of RIOT
Projects
None yet
Development

No branches or pull requests

4 participants