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

wrong sched_pin() on 64bits linux platform when ncpus > 32 #1

Open
zhouchengming1 opened this issue May 3, 2017 · 1 comment
Open

Comments

@zhouchengming1
Copy link

Hi, we found a bug in sched_pin() on 64bits linux platform when ncpus > 32.

The code is like this:
int word = i / (8 * sizeof(unsigned long));
int bit = i % (8 * sizeof(unsigned long));
mask[word] |= (1 << bit);

On 64bits platform, bit can be [0, 63], but (1 << bit) has only 32 bits.
So if we want to bind this task to cpu33, (1 << 33) == (1 << 1), then this task will be bind to cpu1.

If I modify the code like this, I can get correct results.
mask[word] |= ((unsigned long)1 << bit);
Because ((unsigned long)1 << bit) has 64 bits.

Thanks.

@mateoconlechuga
Copy link

You should really be using the stdint.h definitions uint64_t as well.

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

No branches or pull requests

2 participants