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

  • Home
  • SEARCH
  • 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 5847789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:46:06+00:00 2026-05-22T12:46:06+00:00

Is there a reason that opening a device file (rather than a regular file)

  • 0

Is there a reason that opening a device file (rather than a regular file) using numpy’s memmap shouldn’t work?

self.surface = np.memmap('/dev/fb1', dtype=np.uint16, mode='r+', shape=(320,240))

I’m working with a custom kernel module that adds a framebuffer device, which works fine with python’s regular mmap module. But using numpy seems to hang the kernel’s mutex on accessing the filesystem or something (I’m really not sure exactly what’s happening).

My question here is specifically is this something that numpy’s memmap can’t handle and I should go a different way?

I’ve asked another question on unix stackexchange, but I feel like it’s 2 different questions so I’ve posted them both.

Obviously this is on linux (kubuntu maverick with custom kernel module)

Update:

Well, it turns out I can create the memmap fine. The problem it seems is that when I close the process without specifically closing the memmap object and it will just hang on the mutex in the kernel.

I have no idea if this issue is with numpy, or my kernel module, or somewhere else.

  • 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-22T12:46:07+00:00Added an answer on May 22, 2026 at 12:46 pm

    If your code works fine with the python mmap module, you can use it directly instead of numpy.memmap:

    >>> fd = os.open("a", os.O_RDWR)
    >>> buffer = mmap.mmap(fd, 0)
    >>> surface = np.ndarray((320,240), np.uint16, buffer)
    

    This has the other advantage that you have more control over the memory mapping used.

    Now, python’s mmap has its own peculiarities. As the source shows, it calls msync on delallocation. Maybe this is where your program hangs? (You might be able to reproduce your issue with buffer.flush(), which also calls msync). Your solution of calling close() first probably works because it circumvents msync!

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

Sidebar

Related Questions

Is there a specific reason that the EF requires new data providers and can't
Is there any (technical) reason that C# requires all generic type parameters to be
Is there any reason not to set up the install so that major upgrade
While it's my understanding that there's no fundamental reason a program written for 32-bit
Is there any reason something like this would not work? This is the logic
Is there any reason that the compiler cannot optimize the following 2 statements out
I suppose there could be historical reasons for this naming and that other languages
Is there any reason not to use the bitwise operators &, |, and ^
Is there any reason why I should pick JSON over XML, or vice-versa if
Is there any reason to use a varchar field instead of a date field

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.