Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2002-04-30 Dick Porter <dick@ximian.com>
* Completely rewrote the handle waiting code: removed the helper thread and its attendant complexity. All handle waiting is now abstracted into the WaitForSingleObject() and WaitForMultipleObjects() functions. * Implemented inter-process sharing of handles using sysv shared memory. This makes handles even more opaque, with a handle now just an index into an array. 2002-04-30 Dick Porter <dick@ximian.com> * socket-io.c: Cope with SOCKET being an integer rather than a pointer now. * threads.c: Added Thread_free_internal, to deal with thread handle cleanup. Moved calls to handle_store() and handle_remove() to start_wrapper(), so each can only be called once. Allocate synchronisation blocks with GC_malloc(), and use GC finalisation to close the handles. * icall.c: added System.Threading.Thread::Thread_free_internal 2002-04-30 Dick Porter <dick@ximian.com> * acconfig.h: * configure.in: Added option to disable using shared memory for handles 2002-04-30 Dick Porter <dick@ximian.com> * shmdel.c: * scratch.c: * hps.c: * Makefile.am: Some tools to help debug shared memory handles: 'hps' shows handle status, 'scratch' displays info about scratch data (such as handle names), 'shmdel' deletes the shared memory segment. 2002-04-30 Dick Porter <dick@ximian.com> * interp.c: Tell glib to not abort when g_log() etc print recursively 2002-04-30 Dick Porter <dick@ximian.com> * mono.c (main): Tell glib to not abort when g_log() etc print recursively svn path=/trunk/mono/; revision=4166
- Loading branch information
Showing
61 changed files
with
3,837 additions
and
2,170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
#undef NAME_DEV_RANDOM | ||
#undef HAVE_CRYPT_RNG | ||
#undef HAVE_BOEHM_GC | ||
#undef DISABLE_SHARED_HANDLES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
# the handles dir doesn't apply to windows | ||
if PLATFORM_WIN32 | ||
SUBDIRS = utils io-layer monoburg metadata cil dis \ | ||
arch monograph interpreter jit tests benchmark | ||
|
||
else | ||
SUBDIRS = utils io-layer monoburg metadata cil dis \ | ||
arch monograph interpreter jit tests benchmark handles | ||
endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.deps | ||
.libs | ||
Makefile | ||
Makefile.in | ||
hps | ||
scratch | ||
shmdel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
2002-04-30 Dick Porter <dick@ximian.com> | ||
|
||
* shmdel.c: | ||
* scratch.c: | ||
* hps.c: | ||
* Makefile.am: Some tools to help debug shared memory handles: | ||
'hps' shows handle status, 'scratch' displays info about scratch | ||
data (such as handle names), 'shmdel' deletes the shared memory | ||
segment. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
noinst_PROGRAMS = hps scratch shmdel | ||
|
||
INCLUDES = \ | ||
-I$(top_srcdir) \ | ||
$(GMODULE_CFLAGS) \ | ||
$(GLIB_CFLAGS) | ||
|
||
hps_LDADD = \ | ||
../io-layer/libwapi.a \ | ||
$(GLIB_LIBS) \ | ||
$(GMODULE_LIBS) \ | ||
-lm | ||
|
||
scratch_LDADD = \ | ||
../io-layer/libwapi.a \ | ||
$(GLIB_LIBS) \ | ||
$(GMODULE_LIBS) \ | ||
-lm | ||
|
||
shmdel_LDADD = \ | ||
../io-layer/libwapi.a \ | ||
$(GLIB_LIBS) \ | ||
$(GMODULE_LIBS) \ | ||
-lm | ||
|
||
EXTRA_DIST = ChangeLog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
#include <config.h> | ||
#include <glib.h> | ||
|
||
#include <mono/io-layer/io-layer.h> | ||
|
||
/* We're digging into handle internals here... */ | ||
#include <mono/io-layer/handles-private.h> | ||
#include <mono/io-layer/wapi-private.h> | ||
|
||
static const guchar *unused_details (struct _WapiHandleShared *handle); | ||
static const guchar *file_details (struct _WapiHandleShared *handle); | ||
static const guchar *console_details (struct _WapiHandleShared *handle); | ||
static const guchar *thread_details (struct _WapiHandleShared *handle); | ||
static const guchar *sem_details (struct _WapiHandleShared *handle); | ||
static const guchar *mutex_details (struct _WapiHandleShared *handle); | ||
static const guchar *event_details (struct _WapiHandleShared *handle); | ||
static const guchar *socket_details (struct _WapiHandleShared *handle); | ||
static const guchar *find_details (struct _WapiHandleShared *handle); | ||
static const guchar *process_details (struct _WapiHandleShared *handle); | ||
|
||
/* This depends on the ordering of the enum WapiHandleType in | ||
* io-layer/wapi-private.h | ||
*/ | ||
static const char *typename[]={ | ||
"Unused", | ||
"File", | ||
"Console", | ||
"Thread", | ||
"Sem", | ||
"Mutex", | ||
"Event", | ||
"Socket", | ||
"Find", | ||
"Process", | ||
"Error!!" | ||
}; | ||
|
||
/* So does this... */ | ||
static const guchar * (*details[])(struct _WapiHandleShared *)= | ||
{ | ||
unused_details, | ||
file_details, | ||
console_details, | ||
thread_details, | ||
sem_details, | ||
mutex_details, | ||
event_details, | ||
socket_details, | ||
find_details, | ||
process_details, | ||
unused_details, | ||
}; | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
guint32 idx; | ||
guint32 scratch_size; | ||
|
||
_wapi_shared_data=_wapi_shm_attach (&scratch_size); | ||
|
||
_wapi_handle_shared_lock (); | ||
|
||
/* Make sure index 0 is actually unused */ | ||
for(idx=0; idx<_WAPI_MAX_HANDLES; idx++) { | ||
struct _WapiHandleShared *shared=&_wapi_shared_data->handles[idx]; | ||
|
||
if(shared->type!=WAPI_HANDLE_UNUSED) { | ||
g_print ("%4x [%7s] %4u %s (%s)\n", idx, | ||
typename[shared->type], shared->ref, | ||
shared->signalled?"Sg":"Un", | ||
details[shared->type](shared)); | ||
} | ||
} | ||
|
||
_wapi_handle_shared_unlock (); | ||
|
||
exit (0); | ||
} | ||
|
||
static const guchar *unused_details (struct _WapiHandleShared *handle) | ||
{ | ||
return("unused details"); | ||
} | ||
|
||
static const guchar *file_details (struct _WapiHandleShared *handle) | ||
{ | ||
static guchar buf[80]; | ||
guchar *name; | ||
struct _WapiHandle_file *file=&handle->u.file; | ||
|
||
name=_wapi_handle_scratch_lookup_as_string (file->filename); | ||
|
||
g_snprintf (buf, sizeof(buf), | ||
"[%20s] acc: %c%c%c, shr: %c%c%c, attrs: %5u", | ||
name==NULL?(guchar *)"":name, | ||
file->fileaccess&GENERIC_READ?'R':'.', | ||
file->fileaccess&GENERIC_WRITE?'W':'.', | ||
file->fileaccess&GENERIC_EXECUTE?'X':'.', | ||
file->sharemode&FILE_SHARE_READ?'R':'.', | ||
file->sharemode&FILE_SHARE_WRITE?'W':'.', | ||
file->sharemode&FILE_SHARE_DELETE?'D':'.', | ||
file->attrs); | ||
|
||
if(name!=NULL) { | ||
g_free (name); | ||
} | ||
|
||
return(buf); | ||
} | ||
|
||
static const guchar *console_details (struct _WapiHandleShared *handle) | ||
{ | ||
return(file_details (handle)); | ||
} | ||
|
||
static const guchar *thread_details (struct _WapiHandleShared *handle) | ||
{ | ||
static guchar buf[80]; | ||
struct _WapiHandle_thread *thr=&handle->u.thread; | ||
|
||
g_snprintf (buf, sizeof(buf), | ||
"proc: %p, state: %d, exit: %u, join: %s", | ||
thr->process_handle, thr->state, thr->exitstatus, | ||
thr->joined?"TRUE":"FALSE"); | ||
|
||
return(buf); | ||
} | ||
|
||
static const guchar *sem_details (struct _WapiHandleShared *handle) | ||
{ | ||
static guchar buf[80]; | ||
struct _WapiHandle_sem *sem=&handle->u.sem; | ||
|
||
g_snprintf (buf, sizeof(buf), "val: %5u, max: %5d", | ||
sem->val, sem->max); | ||
|
||
return(buf); | ||
} | ||
|
||
static const guchar *mutex_details (struct _WapiHandleShared *handle) | ||
{ | ||
static guchar buf[80]; | ||
guchar *name; | ||
struct _WapiHandle_mutex *mut=&handle->u.mutex; | ||
|
||
name=_wapi_handle_scratch_lookup_as_string (mut->name); | ||
|
||
g_snprintf (buf, sizeof(buf), "[%20s] own: %5d:%5ld, count: %5u", | ||
name==NULL?(guchar *)"":name, mut->pid, mut->tid, | ||
mut->recursion); | ||
|
||
if(name!=NULL) { | ||
g_free (name); | ||
} | ||
|
||
return(buf); | ||
} | ||
|
||
static const guchar *event_details (struct _WapiHandleShared *handle) | ||
{ | ||
static guchar buf[80]; | ||
struct _WapiHandle_event *event=&handle->u.event; | ||
|
||
g_snprintf (buf, sizeof(buf), "manual: %s", | ||
event->manual?"TRUE":"FALSE"); | ||
|
||
return(buf); | ||
} | ||
|
||
static const guchar *socket_details (struct _WapiHandleShared *handle) | ||
{ | ||
/* Nothing to see here */ | ||
return(""); | ||
} | ||
|
||
static const guchar *find_details (struct _WapiHandleShared *handle) | ||
{ | ||
static guchar buf[80]; | ||
struct _WapiHandle_find *find=&handle->u.find; | ||
|
||
g_snprintf (buf, sizeof(buf), "count: %5d", | ||
find->count); | ||
|
||
return(buf); | ||
} | ||
|
||
static const guchar *process_details (struct _WapiHandleShared *handle) | ||
{ | ||
static guchar buf[80]; | ||
struct _WapiHandle_process *proc=&handle->u.process; | ||
|
||
g_snprintf (buf, sizeof(buf), "pid: %5u", | ||
proc->id); | ||
|
||
return(buf); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include <config.h> | ||
#include <glib.h> | ||
#include <unistd.h> | ||
|
||
#include <mono/io-layer/io-layer.h> | ||
|
||
/* We're digging into handle internals here... */ | ||
#include <mono/io-layer/handles-private.h> | ||
#include <mono/io-layer/wapi-private.h> | ||
|
||
#define HDRSIZE sizeof(struct _WapiScratchHeader) | ||
|
||
static guchar *printable (guchar *data, guint32 datalen) | ||
{ | ||
static guchar buf[32]; | ||
guint32 i; | ||
|
||
if(datalen>=32) { | ||
datalen=31; | ||
} | ||
|
||
for(i=0; i<datalen; i++) { | ||
if(g_ascii_isprint (data[i])) { | ||
buf[i]=data[i]; | ||
} else { | ||
buf[i]='.'; | ||
} | ||
} | ||
buf[i]='\0'; | ||
|
||
return(buf); | ||
} | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
guint32 idx=0; | ||
/* Fix if this changes in shared.c */ | ||
guint32 scratch_size=0; | ||
struct _WapiScratchHeader *hdr; | ||
|
||
_wapi_shared_data=_wapi_shm_attach (&scratch_size); | ||
|
||
_wapi_handle_shared_lock (); | ||
|
||
hdr=(struct _WapiScratchHeader *)&_wapi_shared_data->scratch_base[0]; | ||
if(hdr->flags==0 && hdr->length==0) { | ||
g_print ("Scratch space unused\n"); | ||
_wapi_handle_shared_unlock (); | ||
exit (0); | ||
} | ||
|
||
while(idx<scratch_size) { | ||
hdr=(struct _WapiScratchHeader *)&_wapi_shared_data->scratch_base[idx]; | ||
if(hdr->flags & WAPI_SHM_SCRATCH_FREE) { | ||
g_print ("Free block at %6d (index %6d), length %6d\n", | ||
idx, idx+HDRSIZE, hdr->length); | ||
} else { | ||
guchar *data=&_wapi_shared_data->scratch_base[idx+HDRSIZE]; | ||
|
||
g_print ("Used block at %6d (index %6d), length %6d, [%s]\n", | ||
idx, idx+HDRSIZE, hdr->length, | ||
printable (data, hdr->length)); | ||
} | ||
|
||
idx+=(hdr->length+HDRSIZE); | ||
} | ||
|
||
_wapi_handle_shared_unlock (); | ||
|
||
exit (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <config.h> | ||
#include <glib.h> | ||
|
||
/* We're digging into handle internals here... */ | ||
#include <mono/io-layer/shared.h> | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
_wapi_shm_destroy (); | ||
|
||
exit (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.