Machine-translated by Google. Questions are authored in English.
Top

Discussion

P and Q are amongst the five synchronization objects supported by windows.

P blocks access to a resource until some other thread or process signals that it may be used. Q prevents a block of code being used by more than one thread at a time.

What is P and Q ?

  • A.Event object, Waitable timer
  • B.Event object, critical section object
  • C.Semaphore, waitable timer
  • D.Mutex, critical section object

Answer: B

P is an Event object and Q a critical section object.

A Windows event object blocks threads waiting on it until another thread or process signals it, so it fits P, 'blocks access ... until some other thread or process signals that it may be used'. A critical section object lets only one thread of a process at a time execute a protected block of code, which matches Q.

A waitable timer is signalled when a set time arrives, not by another thread, so it does not fit Q. A semaphore limits access to a count of users, and although a mutex also gives mutual exclusion, it does not fit P, which is signalled rather than owned and released.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.