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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:12:17+00:00 2026-05-11T17:12:17+00:00

Please explain from Linux, Windows perspectives? I am programming in C#, would these two

  • 0

Please explain from Linux, Windows perspectives?

I am programming in C#, would these two terms make a difference. Please post as much as you can, with examples and such….

Thanks

  • 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-11T17:12:17+00:00Added an answer on May 11, 2026 at 5:12 pm

    For Windows, critical sections are lighter-weight than mutexes.

    Mutexes can be shared between processes, but always result in a system call to the kernel which has some overhead.

    Critical sections can only be used within one process, but have the advantage that they only switch to kernel mode in the case of contention – Uncontended acquires, which should be the common case, are incredibly fast. In the case of contention, they enter the kernel to wait on some synchronization primitive (like an event or semaphore).

    I wrote a quick sample app that compares the time between the two of them. On my system for 1,000,000 uncontended acquires and releases, a mutex takes over one second. A critical section takes ~50 ms for 1,000,000 acquires.

    Here’s the test code, I ran this and got similar results if mutex is first or second, so we aren’t seeing any other effects.

    HANDLE mutex = CreateMutex(NULL, FALSE, NULL);
    CRITICAL_SECTION critSec;
    InitializeCriticalSection(&critSec);
    
    LARGE_INTEGER freq;
    QueryPerformanceFrequency(&freq);
    LARGE_INTEGER start, end;
    
    // Force code into memory, so we don't see any effects of paging.
    EnterCriticalSection(&critSec);
    LeaveCriticalSection(&critSec);
    QueryPerformanceCounter(&start);
    for (int i = 0; i < 1000000; i++)
    {
        EnterCriticalSection(&critSec);
        LeaveCriticalSection(&critSec);
    }
    
    QueryPerformanceCounter(&end);
    
    int totalTimeCS = (int)((end.QuadPart - start.QuadPart) * 1000 / freq.QuadPart);
    
    // Force code into memory, so we don't see any effects of paging.
    WaitForSingleObject(mutex, INFINITE);
    ReleaseMutex(mutex);
    
    QueryPerformanceCounter(&start);
    for (int i = 0; i < 1000000; i++)
    {
        WaitForSingleObject(mutex, INFINITE);
        ReleaseMutex(mutex);
    }
    
    QueryPerformanceCounter(&end);
    
    int totalTime = (int)((end.QuadPart - start.QuadPart) * 1000 / freq.QuadPart);
    
    printf("Mutex: %d CritSec: %d\n", totalTime, totalTimeCS);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 199k
  • Answers 199k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer According to the JSR 220: Enterprise JavaBeans 3.0 specifications: 4.6.16… May 12, 2026 at 7:50 pm
  • Editorial Team
    Editorial Team added an answer The function of the same name as the class was… May 12, 2026 at 7:50 pm
  • Editorial Team
    Editorial Team added an answer The lowercase "c" in the reference is normal. Your code… May 12, 2026 at 7:50 pm

Related Questions

One of my colleagues has totally messed up the contents of a directory in
I am trying to compile the following code on Linux using gcc 4.2: #include
This answer to Command line command to auto-kill a command after a certain amount
I get confused with some terms while reading MSDN documents and code samples. What

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.