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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:35:48+00:00 2026-06-11T22:35:48+00:00

I am looking for advices or pointers on how to design a specific part

  • 0

I am looking for advices or pointers on how to design a specific part of a Mac OS X network kernel extension to be as fast and efficient as possible – C language.

Description:
I have two sets of TAILQ lists. One for type A structures, the other for type B structures.
Mostly, I deal with them separately, thus have a lock_mtx for each one. Sometimes, I need to modify A, then B, then both at the same time. It looks like this :

Function1:
{
Modify List or Struct A
Modify List or Struct B
Modify List or Struct A & B
Modify List or Struct B
Modify List or Struct A
}

Function2:
{
Modify List or Struct B
Modify List or Struct A & B
Modify List or Struct A
Modify List or Struct A & B
}

I am not familiar with the use of locks. So I see only two options:
1. Use a single lock to protect both lists. That would be a waste, since it would prevent function modifying A only to execute while a function modifying B only is executing (and vice versa).

  1. Take both locks successively, and release them. That would give me:

.

   Function1:
    {
    lock A
    Modify List or Struct A
    unlock A

    lock B
    Modify List or Struct B
    unlock B

    lock A
    lock B
    Modify List or Struct A & B
    unlock B
    unlock A

    lock B
    Modify List or Struct B
    unlock B

    lock A
    Modify List or Struct A
    unlock A
    }

I feat this would be quite expensive, taking all those locks. Is there a better way to protect cross-modifications of A and B ?

Thanks for your advices.

  • 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-06-11T22:35:49+00:00Added an answer on June 11, 2026 at 10:35 pm

    Initially, I was looking for design advices in the context of the above-asked question.

    Well, it turns out that thought using kernel level mutex seems to be the right call, there are no clear-cut answer. Too much depends on the exact structure of the functions and on the time spent doing side-work that does not require to be carried out in locked context.

    In such situations, the best answer, hinted by dario_ramos and pmjordan, would be to profile viable options and make a choice.

    Thank you all for your help.

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

Sidebar

Related Questions

For the following scenario I am looking for your advices and tips on best
I am looking for pointers, suggestions, links, warnings, ideas and even anecdotical accounts about
Currently, I'm looking for any experiences or advices about test tools on Service Oriented
I'm new in .Net development, and I'm looking for some advices. I've some piece
just looking for some advice, pointers, and suggestions for further reading. I have: 1
I'm looking for solution of C++ class design problem. What I'm trying to achieve
I am looking for some advices for sound-related libraries for C++. My requirements are
Looking for advice on framework and approach for building a modular web application. Primary
I'm looking for advice on how best to handle Signalr hub connections in a
I am looking for advice about how to parse a single list, using two

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.