From: Chris Hanson Date: Fri, 10 May 1996 18:48:03 +0000 (+0000) Subject: Change initialization code to allocate a minimum of 256 file handles X-Git-Tag: 20090517-FFI~5538 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=8e1572f2b4072929e7bf25b6e8dff8344dc70899;p=mit-scheme.git Change initialization code to allocate a minimum of 256 file handles for Scheme. The old default of 20 is too small -- quickly eaten by a small number of subprocesses in Edwin -- and worse, the default is not a constant but depends on the method used to invoke Scheme. The number of file handles can by dynamically changed using a new primitive. The channel table is initialized to 1024 entries, allowing plenty of room for growth should that be desired. --- diff --git a/v7/src/microcode/os2.h b/v7/src/microcode/os2.h index 765488d3d..fa5380809 100644 --- a/v7/src/microcode/os2.h +++ b/v7/src/microcode/os2.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: os2.h,v 1.4 1995/10/30 07:54:29 cph Exp $ +$Id: os2.h,v 1.5 1996/05/10 18:48:03 cph Exp $ -Copyright (c) 1994-95 Massachusetts Institute of Technology +Copyright (c) 1994-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -63,8 +63,6 @@ MIT in each case. */ #include "os2cthrd.h" #include "os2pm.h" -#define OS2_MAX_FILE_HANDLES() 20 - #define FILE_ANY \ (FILE_NORMAL | FILE_HIDDEN | FILE_SYSTEM | FILE_DIRECTORY | FILE_ARCHIVED) diff --git a/v7/src/microcode/os2api.h b/v7/src/microcode/os2api.h index 72b54a880..7830ca427 100644 --- a/v7/src/microcode/os2api.h +++ b/v7/src/microcode/os2api.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: os2api.h,v 1.8 1996/05/09 20:20:58 cph Exp $ +$Id: os2api.h,v 1.9 1996/05/10 18:47:42 cph Exp $ Copyright (c) 1994-96 Massachusetts Institute of Technology @@ -94,8 +94,10 @@ enum syscall_names syscall_dos_set_fh_state, syscall_dos_set_file_ptr, syscall_dos_set_file_size, + syscall_dos_set_max_fh, syscall_dos_set_mem, syscall_dos_set_path_info, + syscall_dos_set_rel_max_fh, syscall_dos_start_timer, syscall_dos_stop_timer, syscall_dos_wait_child, @@ -873,8 +875,10 @@ enum syserr_names #define dos_set_fh_state DosSetFHState #define dos_set_file_ptr DosSetFilePtr #define dos_set_file_size DosSetFileSize +#define dos_set_max_fh DosSetMaxFH #define dos_set_mem DosSetMem #define dos_set_path_info DosSetPathInfo +#define dos_set_rel_max_fh DosSetRelMaxFH #define dos_start_timer DosStartTimer #define dos_stop_timer DosStopTimer #define dos_wait_child DosWaitChild @@ -944,8 +948,10 @@ static char * syscall_names_table [] = "dos-set-fh-state", "dos-set-file-ptr", "dos-set-file-size", + "dos-set-max-fh", "dos-set-mem", "dos-set-path-info", + "dos-set-rel-max-fh", "dos-start-timer", "dos-stop-timer", "dos-wait-child", diff --git a/v7/src/microcode/os2io.c b/v7/src/microcode/os2io.c index 13efc6ddd..ce8a8aa7f 100644 --- a/v7/src/microcode/os2io.c +++ b/v7/src/microcode/os2io.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: os2io.c,v 1.6 1996/05/09 20:21:39 cph Exp $ +$Id: os2io.c,v 1.7 1996/05/10 18:47:58 cph Exp $ Copyright (c) 1994-96 Massachusetts Institute of Technology @@ -46,10 +46,29 @@ struct channel * OS2_channel_table; Tchannel * OS2_channel_pointer_table; const int OS_have_select_p = 1; +#ifndef OS2_DEFAULT_MAX_FH +#define OS2_DEFAULT_MAX_FH 256 +#endif + +/* Set this to a larger size than OS2_DEFAULT_MAX_FH, because the + maximum number of file handles can be increased dynamically by + calling a primitive. */ +#ifndef OS2_DEFAULT_CHANNEL_TABLE_SIZE +#define OS2_DEFAULT_CHANNEL_TABLE_SIZE 1024 +#endif + void OS2_initialize_channels (void) { - OS_channel_table_size = (OS2_MAX_FILE_HANDLES ()); + { + LONG req_max_fh = 0; + ULONG current_max_fh; + STD_API_CALL (dos_set_rel_max_fh, ((&req_max_fh), (¤t_max_fh))); + req_max_fh = (OS2_DEFAULT_MAX_FH - current_max_fh); + if (req_max_fh > 0) + STD_API_CALL (dos_set_rel_max_fh, ((&req_max_fh), (¤t_max_fh))); + } + OS_channel_table_size = OS2_DEFAULT_CHANNEL_TABLE_SIZE; OS2_channel_table = (OS_malloc (OS_channel_table_size * (sizeof (struct channel)))); OS2_channel_pointer_table = diff --git a/v7/src/microcode/pros2fs.c b/v7/src/microcode/pros2fs.c index 4c7055d2d..d524a7850 100644 --- a/v7/src/microcode/pros2fs.c +++ b/v7/src/microcode/pros2fs.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: pros2fs.c,v 1.15 1995/11/06 21:52:24 cph Exp $ +$Id: pros2fs.c,v 1.16 1996/05/10 18:47:52 cph Exp $ -Copyright (c) 1994-95 Massachusetts Institute of Technology +Copyright (c) 1994-96 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -414,3 +414,14 @@ DEFINE_PRIMITIVE ("OS2-COPY-FILE", Prim_OS2_copy_file, 2, 2, 0) OS_file_copy ((STRING_ARG (1)), (STRING_ARG (2))); PRIMITIVE_RETURN (UNSPECIFIC); } + +DEFINE_PRIMITIVE ("OS2-SET-REL-MAX-FH", Prim_OS2_set_rel_max_fh, 1, 1, 0) +{ + PRIMITIVE_HEADER (1); + { + LONG req_max_fh = (arg_integer (1)); + ULONG current_max_fh; + STD_API_CALL (dos_set_rel_max_fh, ((&req_max_fh), (¤t_max_fh))); + PRIMITIVE_RETURN (ulong_to_integer (current_max_fh)); + } +}