Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6599295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:28:18+00:00 2026-05-25T18:28:18+00:00

Question eventfd() is a new system call available in Linux since 2.6.22. The call

  • 0

Question

eventfd() is a new system call available in Linux since 2.6.22. The call signature is

int eventfd(unsigned int initval, int flags);

I am making use of this call in constructing a new light saberLock class that’s usable in a polling loop.

The Python Lock object starts in an unblocked state. My use of eventfd requires then that the initial value be non-zero. If the value is internally a uint64_t,

The object contains an
unsigned 64-bit integer (uint64_t) counter that is maintained by the
kernel.

why is the initial value argument of type unsigned int?

Overt Detail

If I use non-zero values as the unlocked state of the Lock, releases are done by writing. Multiple releases without intervening acquires, are erroneous and need to fail. This requires that writing should fail when the event object contains a non-zero value. In its default mode, the event object will add values posted to it up to (uint64_t)0xfffffffffffffffe, before blocking write calls. To detect this situation I will do a nonblocking write that pushes the value over this maximum triggering this circumstance:

If the addition would cause the counter’s
value to exceed the maximum, then the write(2) either blocks
until a read(2) is performed on the file descriptor, or fails
with the error EAGAIN if the file descriptor has been made non‐
blocking.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:28:19+00:00Added an answer on May 25, 2026 at 6:28 pm

    If I understand you correctly, you want to have the state of this beast to alternate between 0 and UINT64_MAX-1?

    The type of the initial value is probably just there for historical reasons. Once that such an interface is used it sticks and it is difficult to change it afterwards.

    If you need the value to be initially UINT64_MAX-1 why not just call eventfd with a 0 argument and do a write with UINT64_MAX-1 immediately after, before you propagate the file descriptor to anybody else:

    int ev = eventfd(0, 0);
    write(ev, &(uint64_t const){ UINT64_MAX-1 }, sizeof(uint64_t));
    

    (well you’ll add the error checking code, don’t you)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question Can I build a image database/library that has an e-commerce style checkout system
Question: I need to read a CSV file. I use the FileHelpers library to
Question is self explanatory, again I need an alternativs in cocos2d android to use
I'm fairly sure this is a template question, since I can't seem to solve
Question: I use the bidirectional dicionary class I found here: Bidirectional 1 to 1
Question What's the full code to enable jQuery on a page and then use
Question as stated in the title.
Question is pretty self explanitory. I want to do a simple find and replace,
Question Alright, I'm confused by all the buzzwords and press release bingo going on.
Question in the title. And what happens when all 3 of $_GET[foo] , $_POST[foo]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.