From Operating System Concepts by  Abraham Silberschatz, Peter B. Galvin, Greg Gagne5.8.3 Implementing a Monitor Using SemaphoresWe now consider a possible implementation of the monitor mechanism  using semaphores. For each monitor, a semaphore mutex (initialized  to 1) is provided. A process must execute wait(mutex) before entering  the monitor and must execute signal(mutex) after leaving the monitor.Since a signaling process must wait until the resumed process either  leaves or waits, an additional semaphore, next, is introduced,  initialized to 0. The signaling processes can use next to suspend  themselves. An integer variable next count is also provided to count  the number of processes suspended on next. Thus, each external  function F is replaced bywait(mutex);...body of F...if (next count > 0)    signal(next);else    signal(mutex);Mutual exclusion within a monitor is ensured.Since the semaphore mutex is initialized to 1, is it used for limiting at most one process can be inside the monitor?The semaphore next means  the number of processes suspended on next. Are these processes suspended on next all inside a monitor? If the answers to the above two questions are yes, do they contradict each other?If no, how does a monitor work actually?Thanks.
Implement a monitor in terms of semaphores
concurrency;operating systems;synchronization