/* Close the mailbox with handle q */ int mbox_close(int q) { mbox_t *box; if (key < 0 || key >= MAX_MBOX) return -1; box = Q[key]; lock_acquire(&box->l); /* We could assert here that box->used > 0 */ box->used--; lock_release(&box->l); return 1; }