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

Wrap raw task routine with an platform specific wrapper #700

Merged
merged 1 commit into from
Jun 19, 2021

Conversation

Joshua-Anderson
Copy link
Contributor

Originating Project/Creator
Affected Component Os/Tasks
Affected Architectures(s)
Related Issue(s) fixes #661
Has Unit Tests (y/n) n
Builds Without Errors (y/n) y
Unit Tests Pass (y/n) y
Documentation Included (y/n) n

Change Description

Instead of calling a user provided task routine directly, call the routine from a platform specific task wrapper function.

Rationale

Different platforms have different function definitions for task routines.

  • Pthreads are void * task(void *)
  • VxWorks is int task(int arg1, ..., int arg10)

F' provides a generic task definition: void task(void *). Right now we're force casting this function to the OS specific function definition. However, casting a function with a void return value to functions with non-void return values is undefined behavior that should be avoided (and is also triggering static analysis warnings). A platform-specific wrapper is used as the task entrypoint, which then calls the F' task entrypoint.

Future Work

The VxWorks task implmentation should be updated to use this new pattern.
For consistency, we may want to update the bare metal schedule to use the execRoutine function.

Os/Task.hpp Outdated Show resolved Hide resolved
@Joshua-Anderson
Copy link
Contributor Author

@LeStarch updated with feedback from our discussion yesterday.

Copy link
Collaborator

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

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

Need some safety asserts, otherwise I like this approach.

@timcanham do you have thoughts on this implementation?

Os/Posix/Task.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@LeStarch LeStarch left a comment

Choose a reason for hiding this comment

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

Looks ok to me!

@LeStarch LeStarch merged commit 48d355a into nasa:devel Jun 19, 2021
@Joshua-Anderson Joshua-Anderson deleted the task-routine-wrapper branch June 20, 2021 16:17
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

Successfully merging this pull request may close these issues.

Os::Task::taskRoutine not compliant with POSIX Thread Entrypoint
2 participants