Skip to content

sem: initial import of a lightweight semaphore layer#3549

Merged
miri64 merged 7 commits intoRIOT-OS:masterfrom
miri64:sem/feat/initial
Oct 19, 2015
Merged

sem: initial import of a lightweight semaphore layer#3549
miri64 merged 7 commits intoRIOT-OS:masterfrom
miri64:sem/feat/initial

Conversation

@miri64
Copy link
Copy Markdown
Member

@miri64 miri64 commented Aug 3, 2015

Reinstitutes semaphores as their own module and takes some POSIX dependent stuff out. Also moves it from a purely concept based scheduler magic to an IPC-based concept to allow for wait timeouts.
This is the first PR in the effort to port lwIP for RIOT.

@miri64 miri64 added Area: POSIX Area: POSIX API wrapper Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Aug 3, 2015
@miri64 miri64 added this to the Release 2015.06 milestone Aug 3, 2015
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.

This block could be replaced by calls to atomic_cas et. al. (atomic.h)

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.

Can you explain to me how?

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.

on second thought, it might not really give any benefits and only make the code less readable, ignore my comment for now. I did not think about the if (value == 0) case before.

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.

Okay :-)

@miri64 miri64 mentioned this pull request Aug 3, 2015
6 tasks
@miri64 miri64 force-pushed the sem/feat/initial branch from d8737e4 to de9f971 Compare August 4, 2015 17:18
@miri64 miri64 assigned jnohlgard and unassigned Kijewski Aug 5, 2015
sys/sem/sem.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.

while ((next = priority_queue_remove_head(&sem->queue)) != NULL) { or you'll have a loop.

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.

Well I definitely want a loop, just not an endless one. Anyway: fixed.

@Kijewski
Copy link
Copy Markdown
Contributor

Please see miri64#15, I'd propose an extra argument so spurious messages received while waiting for the semaphore are not lost.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Aug 21, 2015

Took it.

Makefile.dep 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.

sem needs it own section, since it depends on vtimer.

@Kijewski
Copy link
Copy Markdown
Contributor

ACK but for the Makefile.dep comment. Squash and merge when Travis is happy. I am curious about #3551. :)

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Aug 21, 2015

Mh… actually. Since your fix tests/posix_semaphore is not working anymore. I'm still investigating.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Aug 21, 2015

m( a clean helped very much

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Aug 21, 2015

As a bonus I adapted the posix semaphores to the same hierarchy I'm trying to introduce with sockets. (posix_semaphore is now a submodule of posix)

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

@authmillenon please squash

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Aug 24, 2015

Squashed

@miri64 miri64 modified the milestones: Release NEXT MAJOR, Release 2015.08 Sep 2, 2015
@Kijewski
Copy link
Copy Markdown
Contributor

Needs rebase

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Sep 10, 2015

Rebased

@jnohlgard
Copy link
Copy Markdown
Member

@Kijewski would you like to take over this assignment? I don't think I will have time to review this properly in the foreseeable future.

@Kijewski
Copy link
Copy Markdown
Contributor

@authmillenon, did you only move posix_sem into its own module since my last review? If yes, then ACK.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Sep 16, 2015

I'm not sure, but think so.

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Oct 15, 2015

Oops, missed a comment.

@Kijewski
Copy link
Copy Markdown
Contributor

Well most of the code you commented on was by @Kijewski, so I fixed it ;-)

I deny any responsibility for my errors!! :D

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.

without timeout

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.

missing -EAGAIN

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Oct 16, 2015

Addressed (not squashed immediately, since this change is a little bigger).

@miri64 miri64 force-pushed the sem/feat/initial branch 2 times, most recently from fc07cdc to f42e867 Compare October 16, 2015 14:37
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.

(better to comment in the PR than in the commit)
remove the leading underscore and add a trailing if you like

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Oct 16, 2015

Addressed comments

@jnohlgard
Copy link
Copy Markdown
Member

I realized that the posix specifications and our sem module differ in the return value. The posix documents specify that we should return -1 on error and set errno. Riot doesn't use errno except for posix compatibility functions. One solution is to modify the posix header to apply a thin wrapper on the riot functions, but there is a name collision between posix semaphore.h and riot sem.
Thoughts?

@RIOT-notifier
Copy link
Copy Markdown

RIOT-notifier commented Oct 17, 2015 via email

@jnohlgard
Copy link
Copy Markdown
Member

@authmillenon
OK, I'll ACK the proposed implementation. Can you create a new issue as a reminder that the return value is not POSIX compliant?

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Oct 19, 2015

Done: #4109

@jnohlgard
Copy link
Copy Markdown
Member

ACK, merge when Travis agrees

@miri64
Copy link
Copy Markdown
Member Author

miri64 commented Oct 19, 2015

Squashed

miri64 added a commit that referenced this pull request Oct 19, 2015
sem: initial import of a lightweight semaphore layer
@miri64 miri64 merged commit 3d4f373 into RIOT-OS:master Oct 19, 2015
@miri64 miri64 deleted the sem/feat/initial branch October 19, 2015 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: POSIX Area: POSIX API wrapper CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants