0

I want to release the lock I've acquired within the main process and hand it over to a specific thread. Is there a way I can do this? I'm using the pthreads library

  • With a hypothetical `pthread_mutex_send()`, how would you know what the receiving thread is doing when the send occurs? Or how would the other thread know when it had just received the lock? Through some sort of event mechanism? Or how would the receiver check that it already had the lock? In my mind I got lost, speculating that perhaps what you are really looking for is some sort of lightweight intraprocess IPC mechanism. – Leif Strand May 04 '21 at 03:23

1 Answers1

0

I want to release the lock I've acquired within the main process and hand it over to a specific thread.

This implies that multiple threads want to acquire this lock.

If it matters which one of these threads actually gets it, your design is very likely wrong.

Is there a way I can do this?

No.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • So I'm simulating a mesh network running ospf where links and routers can randomly defect. Should I not multithread this? Should each router be represented by a child process instead? – AnonymousJohnson May 05 '21 at 01:47
  • 1
    @AnonymousJohnson I don't believe you've supplied nearly enough details to answer any of the questions in your comment. I suggest accepting this answer and asking a new question, describing your problem _and_ proposed design in sufficient detail for someone to do a "design review". – Employed Russian May 05 '21 at 01:56