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

GetCpuCount: using get_nprocs() #1322

Merged
merged 2 commits into from
Apr 11, 2022
Merged

GetCpuCount: using get_nprocs() #1322

merged 2 commits into from
Apr 11, 2022

Conversation

inPhraZ
Copy link
Contributor

@inPhraZ inPhraZ commented Mar 14, 2022

Originating Project/Creator
Affected Component Os
Affected Architectures(s) Linux
Related Issue(s) None
Has Unit Tests (y/n) Yes
Builds Without Errors (y/n) Yes
Unit Tests Pass (y/n) Yes
Documentation Included (y/n) N/A

Change Description

Modifying getCpuCount implementation in Linux.

Rationale

get_nprocs() tests different ways to get the cpuCount.
Therefore, if reading from /proc/stat encounters an error, other methods will be tested.

Testing/Review Recommendations

https://code.woboq.org/userspace/glibc/sysdeps/unix/sysv/linux/getsysstats.c.html#__get_nprocs

Future Work

None

get_nprocs() tests different ways to get the cpuCount.
Therefore, if reading from /proc/stat encounters an error,
other methods will be tested.
@github-actions
Copy link

github-actions bot commented Mar 14, 2022

@check-spelling-bot Report

Unrecognized words, please review:

  • sysinfo
Previously acknowledged words that are now absent aadl Accu adoc asciidoctor autodetect autonumbering awt bavail bbd bc bootup capout chown Classloader classpath componentaction compositestructures concat configurator creatingdocsetswithdoxygen Dinstall dll doall Donatas donsim ecore eps errstr esac fprim getenv gethostbyname getmtime gmail Gnd GNDIF groupadd groupmod hdp HOMEPAGE hostent ifchange IFXML IJET includefile inorder INSTALLDIR instanceof interoperability isfgen isfpluginexec isfxmlwriter itcl javabuilder javac javanature javax jdt jf JFile jmi JOption junit kevensen magicdraw mcternan mdbasiccomponents mdinternalstructures mdkernel mdports mdprofiles mdxml mdzip memoize mngr mpmcs mscgen nasafprime netdb Netscape's NGAT nh nio nomagic nondetached nroff OMG's OS'es placeholders PLUGINDIR Prepends println propvals refman RHEL RPISCHEDCONTEXTS saikiranra setuptools Simkunas SOCKETIPDRIVERTYPES SQL's sramanan startword strcat strcpy submenu tcl templating textui tgz tmpd tmpdir toclevels toolbar ubuntu uk ul uml useradd usermod ve virtualenv vmsize vn watney wget workaround workspaces xargs Xmx Xss Xvfb
Some files were were automatically ignored

These sample patterns would exclude them:

^Drv/LinuxGpioDriver/LinuxGpioDriver\.hpp$
^Drv/LinuxSpiDriver/LinuxSpiDriver\.hpp$

You should consider adding them to:

.github/actions/spelling/excludes.txt

File matching is via Perl regular expressions.

To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.

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:inPhraZ/fprime.git repository
on the SysResources 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);
'
(cat '.github/actions/spelling/excludes.txt' - <<EOF
$should_exclude_patterns
EOF
) |grep .|
sort -f |
uniq > '.github/actions/spelling/excludes.txt.temp' &&
mv '.github/actions/spelling/excludes.txt.temp' '.github/actions/spelling/excludes.txt'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/nasa/fprime/issues/comments/1066753900" > "$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")
  

should_exclude_patterns=$(perl -e '$/=undef;
$_=<>;
exit unless s{(?:You should consider excluding directory paths|You should consider adding them to).*}{}s;
s{.*These sample patterns would exclude them:}{}s;
s{.*\`\`\`([^`]*)\`\`\`.*}{$1}m;
print' < "$comment_body" | grep . || true)

update_files
rm $comment_body
git add -u

@LeStarch LeStarch self-requested a review April 11, 2022 21:42
@LeStarch LeStarch merged commit 615df3f into nasa:devel Apr 11, 2022
@inPhraZ inPhraZ deleted the SysResources branch April 12, 2022 12:19
LeStarch added a commit that referenced this pull request Jun 29, 2022
* GetCpuCount: using get_nprocs()

get_nprocs() tests different ways to get the cpuCount.
Therefore, if reading from /proc/stat encounters an error,
other methods will be tested.

* lestarch: sp

Co-authored-by: M Starch <LeStarch@googlemail.com>
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.

2 participants