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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:55:33+00:00 2026-06-12T09:55:33+00:00

So if a thread locks a mutex and then starts a hrtimer. In the

  • 0

So if a thread locks a mutex and then starts a hrtimer. In the timer handler callback function, can I unlock that mutex?

I ask this because I have seen in the mutex.h file:
“only the owner can unlock the mutex”
“task may not exit with mutex held”
“mutexes may not be used in hardware or software interrupt contexts such as tasklets and timers”

So is the timer handler executed in the interrupt context? In that context, the mutex can not be unlocked because the owner is unknow? So maybe I should use semaphore?

Thanks,


@Andy Ross Hi, thank you for your reply.I can not type too many words in comment. What I am going to do is a little difficult to explain. For example, we have 4 cores on one socket. core 0 wants to increase its frequency. To to this, it first needs to increase the socket voltage(voltage change is socket level) then change the frequency. During the change process(normally changing voltage will take some time),other core may also want to change the socket’s voltage which should not be allowed. So core 0 first locks a mutex, then issue the change of the voltage command,start a timer and immediately return to run other tasks. When the timer expires, it will check whether the voltage change has been finished or not. If so, it will change the frequency of the core and then unlock the mutex to allow other cores to change the socket’s voltage. So the mutex is socket level.
I think maybe I can use a sleep. If other core tries to change the voltage before the voltage change has finished, they will do a nanosleep() for example.

  • 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-12T09:55:36+00:00Added an answer on June 12, 2026 at 9:55 am

    The answer is NO. Timer runs in other thread. Only the same thread can unlock.

    For you problem, you should use a state flag/count in and update it with atomic_set and friends. Use that flag to identify the status, don’t hold a mutex that long.

    If you need to queue up voltage change request, use a queue. Blocking a process that long is never a wise idea.

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

Sidebar

Related Questions

Having mutex locks for critical section says that more than one thread won't be
I have a java code that looks like this: //UI thread //Some code Job
The function header for pthread_create looks like this: int pthread_create(pthread_t * thread, const pthread_attr_t
I'm refactoring some time consuming function so that it can be called from a
I'm using pthread_mutex_trylock to lock the mutex on a struct so that it can
UPDATED: Is there a thread-safe, lock-free and available on all Linux distros increment function
The question here is: If a thread that acquiring an exclusive lock to an
My .bashrc looks something like this... export PERL5LIB=/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0/${PLAT}-thread-multi export PERL5LIB=${PERL5LIB}:/tools/perl/Linux/${PLAT}/lib/perl5/5.10.0 function dev { export
I have a table that looks like this: <table> <thead> <!-- random table headings
If the locks make sure only one thread accesses the locked data at a

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.