From: Ben Gras Date: Fri, 30 Jun 2006 14:40:29 +0000 (+0000) Subject: Grant system dynamic-only. X-Git-Tag: v3.1.3~270 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=1561067ee43a6403a20059e47c97a0e32ed61a93;p=minix.git Grant system dynamic-only. --- diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 74eb771cc..00b2b1c4e 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -21,7 +21,7 @@ OBJ = main.o pci.o pci_table.o all build: $(DRIVER) $(DRIVER): $(OBJ) $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS) - install -S 4096 $(DRIVER) + install -S 16k $(DRIVER) # install with other drivers install: /usr/sbin/$(DRIVER) diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 64193dd97..2934deadc 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -212,6 +212,7 @@ PUBLIC void main(void) continue; } case DIAGNOSTICS: /* a server wants to print some */ + printf("WARNING: old DIAGNOSTICS from %d\n", tty_mess.m_source); do_diagnostics(&tty_mess, 0); continue; case DIAGNOSTICS_S: diff --git a/include/minix/safecopies.h b/include/minix/safecopies.h index 53366e1d2..293ca2162 100644 --- a/include/minix/safecopies.h +++ b/include/minix/safecopies.h @@ -69,7 +69,6 @@ _PROTOTYPE( cp_grant_id_t cpf_grant_direct, (endpoint_t, vir_bytes, size_t, int) _PROTOTYPE( cp_grant_id_t cpf_grant_indirect, (endpoint_t, endpoint_t, cp_grant_id_t)); _PROTOTYPE( cp_grant_id_t cpf_grant_magic, (endpoint_t, endpoint_t, vir_bytes, size_t, int)); _PROTOTYPE( int cpf_revoke, (cp_grant_id_t grant_id)); -_PROTOTYPE( int cpf_preallocate, (cp_grant_t *, int)); _PROTOTYPE( int cpf_lookup, (cp_grant_id_t g, endpoint_t *ep, endpoint_t *ep2)); _PROTOTYPE( int cpf_getgrants, (cp_grant_id_t *grant_ids, int n)); diff --git a/lib/other/Makefile.in b/lib/other/Makefile.in index 05ae64f23..8f99cff13 100644 --- a/lib/other/Makefile.in +++ b/lib/other/Makefile.in @@ -6,6 +6,7 @@ LIBRARIES=libc libc_FILES=" \ _brk.c \ + _sbrk.c \ _devctl.c \ __pm_findproc.c \ _getnpid.c \ diff --git a/lib/other/_brk.c b/lib/other/_brk.c index 391b36e18..5ce5e0f63 100755 --- a/lib/other/_brk.c +++ b/lib/other/_brk.c @@ -27,18 +27,3 @@ char *addr; return(0); } - -PUBLIC char *sbrk(incr) -int incr; -{ - char *newsize, *oldsize; - - oldsize = _brksize; - newsize = _brksize + incr; - if ((incr > 0 && newsize < oldsize) || (incr < 0 && newsize > oldsize)) - return( (char *) -1); - if (brk(newsize) == 0) - return(oldsize); - else - return( (char *) -1); -} diff --git a/lib/other/_sbrk.c b/lib/other/_sbrk.c new file mode 100755 index 000000000..9f95f5817 --- /dev/null +++ b/lib/other/_sbrk.c @@ -0,0 +1,20 @@ +#include +#define sbrk _sbrk +#include + +extern char *_brksize; + +PUBLIC char *sbrk(incr) +int incr; +{ + char *newsize, *oldsize; + + oldsize = _brksize; + newsize = _brksize + incr; + if ((incr > 0 && newsize < oldsize) || (incr < 0 && newsize > oldsize)) + return( (char *) -1); + if (brk(newsize) == 0) + return(oldsize); + else + return( (char *) -1); +} diff --git a/lib/syslib/safecopies.c b/lib/syslib/safecopies.c index 87f03411b..0559f976f 100644 --- a/lib/syslib/safecopies.c +++ b/lib/syslib/safecopies.c @@ -38,54 +38,16 @@ } PRIVATE cp_grant_t *grants = NULL; -PRIVATE int ngrants = 0, dynamic = 1; - -PUBLIC int -cpf_preallocate(cp_grant_t *new_grants, int new_ngrants) -{ -/* Use a statically allocated block of grants as our grant table. - * This means we can't grow it dynamically any more. - * - * This function is used in processes that can't safely call realloc(). - */ - int s; - - /* If any table is already in place, we can't change it. */ - if(ngrants > 0) { - errno = EBUSY; - return -1; - } - - /* Update kernel about the table. */ - if((s=sys_setgrant(new_grants, new_ngrants))) { - return -1; - } - - /* Update internal data. dynamic = 0 means no realloc()ing will be done - * and we can't grow beyond this size. - */ - grants = new_grants; - ngrants = new_ngrants; - dynamic = 0; - - return 0; -} +PRIVATE int ngrants = 0; PRIVATE void cpf_grow(void) { -/* Grow the grants table if possible. If a preallocated block has been - * submitted ('dynamic' is clear), we can't grow it. Otherwise, realloc(). - * Caller is expected to check 'ngrants' to see if the call was successful. - */ +/* Grow the grants table if possible. */ cp_grant_t *new_grants; cp_grant_id_t g; int new_size; - /* Can't grow if static block already assigned. */ - if(!dynamic) - return; - new_size = (1+ngrants)*2; assert(new_size > ngrants); diff --git a/lib/sysutil/kputc.c b/lib/sysutil/kputc.c index ba1f23fe9..f9d8db313 100644 --- a/lib/sysutil/kputc.c +++ b/lib/sysutil/kputc.c @@ -25,21 +25,24 @@ int c; #define PRINTPROCS (sizeof(procs)/sizeof(procs[0])) int procs[] = OUTPUT_PROCS_ARRAY; static int firstprint = 1; - static cp_grant_t printgrant_buffer[PRINTPROCS]; static cp_grant_id_t printgrants[PRINTPROCS]; int p; if(firstprint) { + for(p = 0; procs[p] != NONE; p++) { + printgrants[p] = GRANT_INVALID; + } + + firstprint = 0; + /* First time? Initialize grant table; * Grant printing processes read copy access to our - * print buffer. (So buffer can't be on stack!) + * print buffer forever. (So buffer can't be on stack!) */ - cpf_preallocate(printgrant_buffer, PRINTPROCS); for(p = 0; procs[p] != NONE; p++) { printgrants[p] = cpf_grant_direct(procs[p], print_buf, sizeof(print_buf), CPF_READ); } - firstprint = 0; } for(p = 0; procs[p] != NONE; p++) { diff --git a/servers/fs/Makefile b/servers/fs/Makefile index fbd28cd5e..64bf4b26c 100644 --- a/servers/fs/Makefile +++ b/servers/fs/Makefile @@ -22,7 +22,7 @@ OBJ = main.o open.o read.o write.o pipe.o dmap.o \ install all build: $(SERVER) $(SERVER): $(OBJ) $(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS) - install -S 1024w $@ + install -S 16k $@ # clean up local files clean: diff --git a/servers/fs/main.c b/servers/fs/main.c index 64c5a03ce..f69cb8db8 100644 --- a/servers/fs/main.c +++ b/servers/fs/main.c @@ -225,22 +225,6 @@ PRIVATE void fs_init() message mess; int s; -/* Maximum number of outstanding grants is one full i/o - * vector, and all processes hanging on SUSPENDed i/o, and - * grants for printf() to tty and log. - * - * Space is declared for it here, and cpf_preallocate() - * uses it internally and internally tells the kernel - * about it. FS then never touches the data again directly, - * only through the cpf_* library routines. - */ -#define NGRANTS (NR_PROCS + NR_IOREQS + 10) - static cp_grant_t grants[NGRANTS]; - - /* Set data copy grant table, as FS can't allocate it dynamically. */ - if(cpf_preallocate(grants, NGRANTS) != OK) - panic(__FILE__,"cpf_preallocate failed", NO_NUM); - /* Initialize the process table with help of the process manager messages. * Expect one message for each system process with its slot number and pid. * When no more processes follow, the magic process number NONE is sent.