Q1) Is mailbox used for synchronisation or as a communication channel (FIFO ordered) between processes?
It is a built-in class like any other class but, has built-in methods that operate on FIFO ordered queue, to perform desired operations.
Q2) Mailbox methods are built-in std package described as Put (), Get (), Peek () as tasks and others new (), num () try_put (), try_get () and try_peek as functions. Do these methods provide synchronisation? If yes, how? or perform control over mailbox communication channel? How?
Q3) What if we write our own methods in a package and try implement queue instead of mailbox? Is it possible? If yes, how?
I have read through your provided link, it has help me but not entirely. I’m a bit puzzled about how semaphores are used to access control ends of queues in mailbox. An answer in your link reads, when multiple threads want to write and read data, mailbox uses atomic test-and-set operation of semaphore which I’m not sure, how?. If you could give a brief idea about atomic test-and-set operation of semaphore. It should convince me to believe that mailbox is used for both synchronisation and as a communication channel between processes.