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

futex system call #2

Open
yashrajkakkad opened this issue Oct 24, 2021 · 1 comment
Open

futex system call #2

yashrajkakkad opened this issue Oct 24, 2021 · 1 comment

Comments

@yashrajkakkad
Copy link

A key feature of Linux kernel - futex is not yet implemented.

For a start, two operations can be implemented:

  • FUTEX_WAIT - Test if the value at the futex contains the expected value. If so, sleep.
  • FUTEX_WAKE - Wake up a number of waiters waiting on the futex word.

A futex consists of a kernelspace wait queue that is attached to an atomic integer in userspace. I found something similar here which is used for implementing spinlock: wait_queue.rs

References:

@nuta I hope I am going in the right direction. I seek your valuable inputs to get started with the implementation.

@nuta
Copy link
Owner

nuta commented Oct 24, 2021

You're on the right tack, @yashrajkakkad! wait_queue.rs will be helpful to stop/resume threads on a futex. One thing I'd like you to keep in mind is I have never used directory or implemented futex(2). Please let me know if say something incorrect :)

BTW, when you port a new system call, I generally recommend to read its man page: https://man7.org/linux/man-pages/man2/futex.2.html

nuta added a commit that referenced this issue Nov 4, 2021
It helps where an error is constructed:

[   0.585] [7:curl] syscall: close(ffffffffffffffff, 0, 0, 0, 0, 0)
[   0.585] WARN: close: error: EBADF: This error originates from:
    #1: ffff800000184219  kerla::printk::capture_backtrace()+0x79
    #2: ffff8000001dbb13  kerla::result::Error::new()+0x23
    #3: ffff8000001dc0e7  <kerla::result::Error as c...la::result::Errno>>::from()+0x17
    #4: ffff800000211177  <T as core::convert::Into<U>>::into()+0x17
    #5: ffff8000001fcb55  kerla::fs::opened_file::OpenedFileTable::close()+0xa5
    #6: ffff80000010b124  kerla::syscalls::close::<i...yscallHandler>::sys_close()+0xa4
    #7: ffff80000011bf62  kerla::syscalls::SyscallHandler::do_dispatch()+0x4e62
    #8: ffff8000001168fc  kerla::syscalls::SyscallHandler::dispatch()+0x1ac
@nuta nuta added this to the User Multi-threading milestone Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants