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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:14:00+00:00 2026-05-31T13:14:00+00:00

Windows CRITICAL_SECTION is implemented in a way lighter than mutex ( as far as

  • 0

Windows CRITICAL_SECTION is implemented in a way lighter than mutex ( as far as for the lock/unlock perf cost ) By utilizing a spinlock and a semaphore to reduce user/kernel switches.

A mutex require a context switch even if the mutex is not currently owned/locked where a CRITICAL_SECTION will req that only after a period of time sinning on the spin lock ( results in better perf ).

I am new to Android Native dev, having in mind windows CRITICAL_SECTION, is there an equivalent in Native Android?

Is there anything lighter than pthread_mutex_. @ Android? does ‘pthread_mutex_.‘ impose a context switch even if the mutex is not already ~owned/locked~ ( as in windows )?

Having in mind rapid entering/exiting a critical section What is the usage cost of ‘pthread_mutex_.‘ impose ?

Is there a user-mode spinlock @ Native Android ?

Any help will be appreciated.

Nadav at Sophin

  • 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-31T13:14:00+00:00Added an answer on May 31, 2026 at 1:14 pm

    No, the pthread_mutex_lock() in Android’s Bionic libc does not impose a context switch for locking a normal mutex in the uncontended state – a simple atomic compare-and-exchange is used, followed by a memory barrier. Likewise unlocking a mutex does not require a kernel entry if there is no process waiting on it.

    You can find the Bionic implementation of pthread_mutex_lock() and pthread_mutex_unlock() in libc/bionic/pthread.c in the Bionic libc sources and see this yourself.

    In general you can consider pthread_mutex_lock() / pthread_mutex_unlock() to be quite lightweight.

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

Sidebar

Related Questions

Windows 7 has a very nifty way of showing Contributing Artist metadata in Windows
Windows allows configuration of Measurement system to Metric or U.S. Is there a way
I've written a low lock list in C++ on windows 32-bit. I'm getting BIG
I made a very simple spinlock using the Interlocked functions in Windows and tested
OS: Windows Language: C/C++ The design demands to use a mutex variable across process
In Windows environment, is Boost's scoped mutex using WinAPI's critical sections, or something else?
In Delphi 2009 and Windows API, is there a way to detect that a
It seems that using Critical Sections quite a bit in Vista/Windows Server 2008 leads
Windows 2003/IIS 6... I have a virtual directory on a web site that closely
Windows XP start menu is divided into two parts, the left and the right.

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.