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

lestarch: reworking posix tasks #992

Merged
merged 7 commits into from
Sep 16, 2021

Conversation

LeStarch
Copy link
Collaborator

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

Change Description

There were several issues in the Os/Posix/Task.cpp and Os/Posix/TaskRoot.cpp. These were:

  1. Os/Posix/Task.cpp silently dropped priorities, affinity without any indication
  2. Os/Posix/TaskRoot.cpp code-rotted and was no longer kept up-to-date
  3. All posix implementations accepted invalid priorities, stack sizes, without validation or explanation
  4. Ref, RPI deployments both specified invalid stack sizes, invalid priorities, and were incapable of using these settings anyway
  5. Permissions prevent TaskRoot.cpp from running unless user is root.

This PR fixes the above issues by:

  1. Merging TaskRoot into Task.cpp
  2. Clamping out-of-range values to posix defaults (max/min priority, min stack size)
  3. Providing argument-free constructors to use task defaults
  4. Falling back to priority-free tasks when user has not permissions to run priority tasks
  5. Logging warnings when:
  • Out-of-range values are supplied
  • Old function signatures are used
  • Tasks set to use priority and were unable to do so because of permissions

The design of this PR is to keep existing applications running as-is, but produce warnings to indicate corrections that should be made. In a future PR, these warnings will be removed, and users will be forced to upgrade.

Rationale

If a user specifies stack size/priority it should work, not silently be discarded. For users that don't care, a default should be provided that maps to posix defaults. If the user does not have permission, the program should fail.

Testing/Review Recommendations

Future Work

Given this is devel and we don't want to break all users, we have provided warnings for the time being. As we approach release v3.0.0, we need to remove the warnings and replace them with hard-failures forcing users to upgrade.

@LeStarch LeStarch requested a review from timcanham August 31, 2021 17:32
@github-actions
Copy link

github-actions bot commented Aug 31, 2021

@check-spelling-bot Report

Unrecognized words, please review:

  • aruguments
Previously acknowledged words that are now absent differend FIXME followd lgcov lxr setopt
To accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the git@github.com:LeStarch/fprime.git repository
on the update/posix-task-rework branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/nasa/fprime/issues/comments/909444643" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")
  

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u

@LeStarch LeStarch changed the title lestarch: rewokring posix tasks lestarch: reworking posix tasks Aug 31, 2021
@LeStarch LeStarch force-pushed the update/posix-task-rework branch from 78a87d5 to 3079f39 Compare August 31, 2021 17:38
@LeStarch LeStarch force-pushed the update/posix-task-rework branch from 8066b06 to ae37a92 Compare September 2, 2021 16:57
@LeStarch LeStarch force-pushed the update/posix-task-rework branch from 56217a3 to 3f6a902 Compare September 2, 2021 17:39
Copy link
Contributor

@Joshua-Anderson Joshua-Anderson left a comment

Choose a reason for hiding this comment

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

Looks great!

Drv/Ip/SocketReadTask.hpp Outdated Show resolved Hide resolved
@LeStarch LeStarch merged commit a08dd11 into nasa:devel Sep 16, 2021
@LeStarch LeStarch deleted the update/posix-task-rework branch December 14, 2021 21:00
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.

3 participants