New NOTIFY system call! Queued at kernel. Duplicate messages (with same source
and type) are overwritten with newer flags/ arguments. The interface from within the kernel is lock_notify(). User processes can make a system call with notify(). NOTIFY fully replaces the old notification mechanism.
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
* panic abort MINIX due to a fatal error
|
||||
* bad_assertion for debugging
|
||||
* bad_compare for debugging
|
||||
* alloc_bit bit map manipulation
|
||||
* free_bit bit map manipulation
|
||||
* print_bitmap bit map manipulation
|
||||
*/
|
||||
|
||||
#include "kernel.h"
|
||||
@@ -35,6 +38,78 @@ int n;
|
||||
}
|
||||
|
||||
|
||||
/*===========================================================================*
|
||||
* print_bitmap *
|
||||
*===========================================================================*/
|
||||
PUBLIC void print_bitmap(bitmap, nr_bits)
|
||||
bitchunk_t *bitmap;
|
||||
bit_t nr_bits;
|
||||
{
|
||||
bit_t bit_i;
|
||||
|
||||
for (bit_i=0; bit_i < nr_bits; bit_i++) {
|
||||
|
||||
kprintf("%d", GET_BIT(bitmap, bit_i) > 0 );
|
||||
if (! ((bit_i+1) % 8) ) kprintf(" ", NO_ARG);
|
||||
if (! ((bit_i+1) % 64) ) kprintf("\n", NO_ARG);
|
||||
}
|
||||
kprintf("\n", NO_ARG);
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* free_bit *
|
||||
*===========================================================================*/
|
||||
PUBLIC void free_bit(bit_nr, bitmap, nr_bits)
|
||||
bit_t bit_nr;
|
||||
bitchunk_t *bitmap;
|
||||
bit_t nr_bits;
|
||||
{
|
||||
bitchunk_t *chunk;
|
||||
if (bit_nr >= nr_bits) {
|
||||
kprintf("Warning, free_bit: %d illegal index\n", bit_nr);
|
||||
return;
|
||||
}
|
||||
chunk = &bitmap[(bit_nr/BITCHUNK_BITS)];
|
||||
*chunk &= ~(1 << (bit_nr % BITCHUNK_BITS));
|
||||
}
|
||||
|
||||
/*===========================================================================*
|
||||
* alloc_bit *
|
||||
*===========================================================================*/
|
||||
PUBLIC int alloc_bit(bitmap, nr_bits)
|
||||
bitchunk_t *bitmap;
|
||||
bit_t nr_bits;
|
||||
{
|
||||
bitchunk_t *chunk;
|
||||
int nr_chunks;
|
||||
int bit_nr;
|
||||
int i;
|
||||
|
||||
/* Iterate over the words in block. */
|
||||
nr_chunks = BITMAP_CHUNKS(nr_bits);
|
||||
for (chunk = &bitmap[0]; chunk < &bitmap[nr_chunks]; chunk++) {
|
||||
|
||||
/* Does this chunk contain a free bit? */
|
||||
if (*chunk == (bitchunk_t) ~0) continue;
|
||||
|
||||
/* Get bit number from the start of the bit map. */
|
||||
for (i = 0; (*chunk & (1 << i)) != 0; ++i) {}
|
||||
bit_nr = (chunk - &bitmap[0]) * BITCHUNK_BITS + i;
|
||||
|
||||
/* Don't allocate bits beyond the end of the map. */
|
||||
if (bit_nr >= nr_bits) break;
|
||||
|
||||
*chunk |= 1 << bit_nr % BITCHUNK_BITS;
|
||||
return(bit_nr);
|
||||
|
||||
}
|
||||
kprintf("Warning, all %d bits in map busy\n", nr_bits);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if !NDEBUG
|
||||
/*=========================================================================*
|
||||
* bad_assertion *
|
||||
|
||||
Reference in New Issue
Block a user