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 6671833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:26:13+00:00 2026-05-26T03:26:13+00:00

I am making use of the C# code located at the following links to

  • 0

I am making use of the C# code located at the following links to implement a Ram-disk project.

  • Link to description of source code
  • Link to source code

As a summary, the code indicated above makes use of a simple tree structure to store the directories, sub-directories and files. At the root is a MemoryFolder object which stores zero or more ‘MemoryFolder’ objects and/or MemoryFile objects. Each MemoryFolder object in turn stores zero or more MemoryFolder objects and/or MemoryFile objects and so forth up to an unlimited depth.

However, the code is not thread safe. What is the most elegant way of implementing thread safety? In addition, how should the following non-exhaustive list of multithreading requirements for a typical file system be enforced by using the appropriate locking strategy?

  1. The creation of two different folder (each by a different thread) simultaneously under the same
    parent folder can occur concurrently if the thread safe
    implementation allows it. Otherwise, some locking strategy should be
    implemented to only allow sequential creation.

  2. None of the direct or indirect parent folders of the folder
    containing a specific file (that is currently read by another
    thread) propagating all the way up to the root folder can be moved
    or deleted by another thread until the ReadFile thread completes its
    execution.

  3. With regards to each unique file, allows concurrent access for multiple ReadFile threads but restricting access to a single WriteFile thread.

  4. If two separate ReadFile threads (fired almost simultaneously),
    each from a different application attempts to create a folder with
    the same name (assuming that the folder does not already exist
    before both threads are fired), the first thread that enters the
    Ram-Disk always succeeds while the second one always fails. In other
    words, the order of thread execution is deterministic.

  5. The total disk space calculation method GetDiskFreeSpace running
    under a separate thread should not complete its execution until all
    WriteFile threads that are already in progress complete its execution. All subsequent WriteFile threads that have not begun executing are blocked until the GetDiskFreeSpace thread completes its execution.

  • 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-26T03:26:14+00:00Added an answer on May 26, 2026 at 3:26 am

    The easiest way to do this would be to protect the entire tree with a ReaderWriterLockSlim. That allows concurrent access by multiple readers or exclusive access by a single writer. Any method that will modify the structure in any way will have to acquire the write lock, and no other threads will be allowed to read or write to the structure until that thread releases the write lock.

    Any thread that wants to read the structure has to acquire the read lock. Multiple readers can acquire the read lock concurrently, but if a thread wants to acquire the write lock–which means waiting until all existing read locks are released.

    There might be a way to make that data structure lock-free. Doing so, however, could be quite difficult. The reader/writer lock will give you the functionality you want, and I suspect it would be fast enough.

    If you want to share this across processes, that’s another story. The ReaderWriterLockSlim doesn’t work across processes. You could, however, implement something similar using a combination of the synchronization primitives, or create a device driver (or service) that serves the requests, thereby keeping it all in the same process.

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

Sidebar

Related Questions

I use JEditable for making edit field which following code: $(function() { $(.field).editable(http://localhost/index.php/welcome/update_record, {
I'm making use of an open source project that is changing quite frequently. It
if I'm using the sizeof operator and making use of size_t in my code,
I'm making a program use JNI to call some native directives. My code is:
I found some really great code from Matt Gallagher for use with making Undo
Okay so, I have to use an interface in a code I'm making involving
I am making use of PHPMailer to send mail through GMail. The code I
Is Dropbox just making use of iOS libraries (iBooks code?) to read .doc/.docx files
I am making a fund raising website, I want to use Code Igniter as
We have some code that is making use of the new postMessage functionality in

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.