Skip to content

core: add support to see if there are messages available for the curr…#3997

Merged
OlegHahm merged 1 commit intoRIOT-OS:masterfrom
DipSwitch:core_msg_avail_support
Dec 2, 2015
Merged

core: add support to see if there are messages available for the curr…#3997
OlegHahm merged 1 commit intoRIOT-OS:masterfrom
DipSwitch:core_msg_avail_support

Conversation

@DipSwitch
Copy link
Copy Markdown
Member

Add support to check if there are messages queued for the current thread.

This will later be used for -EWOULDBLOCK error code.

@PeterKietzmann PeterKietzmann added Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation Area: core Area: RIOT kernel. Handle PRs marked with this with care! labels Sep 30, 2015
@jnohlgard
Copy link
Copy Markdown
Member

Could you add a simple test case for the new function?

I suggest changing the name to msg_avail to match the naming of other similar functions in the repo (cib_avail, tsrb_avail)

@DipSwitch DipSwitch force-pushed the core_msg_avail_support branch from 1b508e2 to b3440ad Compare September 30, 2015 09:46
@DipSwitch
Copy link
Copy Markdown
Member Author

Addressed name change and unit test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure? This application just uses core. If stm32f0discovery does not fit core we really reevaluate support for this platform ;-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied it from thread_msg but I guess it has insufficient memory there because of 3 threads with printf support, sec ;)

@DipSwitch DipSwitch force-pushed the core_msg_avail_support branch from b3440ad to 9c5a42a Compare September 30, 2015 09:57
core/msg.c Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace sched_threads[sched_active_pid] with sched_active_thread.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copy/pasted the code from _msg_receive should it get changed there aswell?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please, and in msg_send_receive, too. But that should go into a new commit. Could be that I am missing a use case where sched_threads[sched_active_pid] != sched_active_thread, but I think that these two need to match in all cases but for a short moment then switching threads.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sched_threads[sched_active_pid] changes should go in a separate PR. The reviewer needs to look up all write occurences of sched_active_thread and sched_active_pid to ensure that we are not introducing a bug (possibly a race while switching threads) in the message passing system.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gebart So for this PR I keep using sched_threads[sched_active_pid] to be on the save side?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was primarily talking about the existing functions which use sched_threads[sched_active_pid], since it depends on where the function is used if there will be any possible races or not. I guess @Kijewski might have an opinion here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In here you can use sched_active_thread. For the other functions we need to look if they [are/may be] used in interrupt handlers. I am quite sure they must not be called by an interrupt handler, because it would simply make no sense if I am not mistaken.

@OlegHahm OlegHahm added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 1, 2015
@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Dec 1, 2015

@DipSwitch, can you address @Kijewski's latest small comment?

@DipSwitch
Copy link
Copy Markdown
Member Author

Kijewski: Replace sched_threads[sched_active_pid] with sched_active_thread.

Me: I copy/pasted the code from _msg_receive should it get changed there aswell?

Kijewski: Yes, please, and in msg_send_receive, too. But that should go into a new commit. Could be that I am missing a use case where sched_threads[sched_active_pid] != sched_active_thread, but I think that these two need to match in all cases but for a short moment then switching threads.

Do I make a pull request for the other lines as well?

I'll squash if you validated the last commit addressing @Kijewski's points.

@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Dec 2, 2015

Validated. Please squash.

@DipSwitch DipSwitch force-pushed the core_msg_avail_support branch from e89d5a6 to 1c8d81f Compare December 2, 2015 07:37
@DipSwitch
Copy link
Copy Markdown
Member Author

squashed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return -1 if the caller's message queue was not initialized.

@Kijewski
Copy link
Copy Markdown
Contributor

Kijewski commented Dec 2, 2015

Please add the line of documentation about the error case. You can squash immediately.

Other than that: ACK. Needs a seconds ACK, because it's a core change.

@DipSwitch DipSwitch force-pushed the core_msg_avail_support branch from 1c8d81f to 15e8f4e Compare December 2, 2015 08:08
@DipSwitch
Copy link
Copy Markdown
Member Author

Done

@DipSwitch
Copy link
Copy Markdown
Member Author

Travis failed on Ready for CI build on msp430 and armv7

@DipSwitch
Copy link
Copy Markdown
Member Author

Travis is happy

@OlegHahm OlegHahm added this to the Release 2015.12 milestone Dec 2, 2015
@OlegHahm
Copy link
Copy Markdown
Member

OlegHahm commented Dec 2, 2015

ACK and go!

OlegHahm added a commit that referenced this pull request Dec 2, 2015
core: add support to see if there are messages available for the curr…
@OlegHahm OlegHahm merged commit 349d333 into RIOT-OS:master Dec 2, 2015
@DipSwitch DipSwitch deleted the core_msg_avail_support branch December 16, 2015 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: core Area: RIOT kernel. Handle PRs marked with this with care! CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants