Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to retrieve the name of threads
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 7 Aug 2007 18:45:38 +0000 (18:45 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 7 Aug 2007 18:45:38 +0000 (18:45 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@4014 48e7efb5-ca39-0410-a469-dd3cf9ba447f

include/xbt/synchro.h
src/include/xbt/xbt_os_thread.h
src/xbt/xbt_os_thread.c
src/xbt/xbt_rl_synchro.c
src/xbt/xbt_sg_synchro.c

index d77af7e..333df95 100644 (file)
@@ -35,6 +35,8 @@ SG_BEGIN_DECL()
   XBT_PUBLIC(xbt_thread_t) xbt_thread_create(const char *name, void_f_pvoid_t start_routine,void* param);
   XBT_PUBLIC(void) xbt_thread_exit();
   XBT_PUBLIC(xbt_thread_t) xbt_thread_self(void);
   XBT_PUBLIC(xbt_thread_t) xbt_thread_create(const char *name, void_f_pvoid_t start_routine,void* param);
   XBT_PUBLIC(void) xbt_thread_exit();
   XBT_PUBLIC(xbt_thread_t) xbt_thread_self(void);
+  XBT_PUBLIC(const char*) xbt_thread_name(xbt_thread_t t);
+  XBT_PUBLIC(const char*) xbt_thread_self_name(void);
   /* xbt_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
   XBT_PUBLIC(void) xbt_thread_join(xbt_thread_t thread);
   /* Ends the life of the poor victim (not always working if it's computing, but working if it's blocked in the OS) */
   /* xbt_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
   XBT_PUBLIC(void) xbt_thread_join(xbt_thread_t thread);
   /* Ends the life of the poor victim (not always working if it's computing, but working if it's blocked in the OS) */
index b3860d5..e42d2ec 100644 (file)
@@ -31,6 +31,8 @@ SG_BEGIN_DECL()
   XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_create(const char *name,pvoid_f_pvoid_t start_routine,void* param);
   XBT_PUBLIC(void) xbt_os_thread_exit(int *retcode);
   XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_self(void);
   XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_create(const char *name,pvoid_f_pvoid_t start_routine,void* param);
   XBT_PUBLIC(void) xbt_os_thread_exit(int *retcode);
   XBT_PUBLIC(xbt_os_thread_t) xbt_os_thread_self(void);
+  XBT_PUBLIC(const char*) xbt_os_thread_self_name(void);
+  XBT_PUBLIC(const char*) xbt_os_thread_name(xbt_os_thread_t);
   /* xbt_os_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
   XBT_PUBLIC(void) xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return);
   XBT_PUBLIC(void) xbt_os_thread_yield(void);
   /* xbt_os_thread_join frees the joined thread (ie the XBT wrapper around it, the OS frees the rest) */
   XBT_PUBLIC(void) xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return);
   XBT_PUBLIC(void) xbt_os_thread_yield(void);
index 56c15e1..dad3c66 100644 (file)
@@ -66,6 +66,7 @@ void xbt_os_thread_mod_init(void) {
      THROW0(system_error,errcode,"pthread_key_create failed for xbt_self_thread_key");
 
    main_thread=xbt_new(s_xbt_os_thread_t,1);
      THROW0(system_error,errcode,"pthread_key_create failed for xbt_self_thread_key");
 
    main_thread=xbt_new(s_xbt_os_thread_t,1);
+   main_thread->name = (char*)"main";
    main_thread->start_routine = NULL;
    main_thread->param = NULL;
    main_thread->exception = xbt_new(ex_ctx_t, 1);
    main_thread->start_routine = NULL;
    main_thread->param = NULL;
    main_thread->exception = xbt_new(ex_ctx_t, 1);
@@ -111,6 +112,14 @@ xbt_os_thread_t xbt_os_thread_create(const char*name,
    return res_thread;
 }
 
    return res_thread;
 }
 
+const char* xbt_os_thread_name(xbt_os_thread_t t) {
+   return t->name;
+}
+
+const char* xbt_os_thread_self_name(void) {
+   xbt_os_thread_t self = xbt_os_thread_self();
+   return self?self->name:"main";
+}
 void 
 xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return) {
        
 void 
 xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return) {
        
@@ -322,6 +331,15 @@ xbt_os_thread_t xbt_os_thread_create(const char *name,pvoid_f_pvoid_t start_rout
    return t;
 }
 
    return t;
 }
 
+const char* xbt_os_thread_name(xbt_os_thread_t t) {
+   return t->name;
+}
+
+const char* xbt_os_thread_self_name(void) {
+   xbt_os_thread_t t = xbt_os_thread_self();
+   return t?t->name:"main";
+}
+
 void 
 xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return) {
 
 void 
 xbt_os_thread_join(xbt_os_thread_t thread,void ** thread_return) {
 
index 356313f..140bb5c 100644 (file)
@@ -46,6 +46,14 @@ xbt_thread_t xbt_thread_create(const char*name,void_f_pvoid_t* code, void* param
    return res;
 }
 
    return res;
 }
 
+const char* xbt_thread_name(xbt_thread_t t) {
+   return xbt_os_thread_name(t->os_thread);
+}
+
+const char* xbt_thread_self_name(void) {
+   return xbt_os_thread_self_name();
+}
+
 void 
 xbt_thread_join(xbt_thread_t thread) {
    DEBUG1("Join thread %p",thread);
 void 
 xbt_thread_join(xbt_thread_t thread) {
    DEBUG1("Join thread %p",thread);
index 3788d37..d78d28e 100644 (file)
@@ -50,6 +50,15 @@ xbt_thread_t xbt_thread_create(const char*name,void_f_pvoid_t* code, void* param
    return res;
 }
 
    return res;
 }
 
+const char* xbt_thread_name(xbt_thread_t t) {
+   return t->name;
+}
+
+const char* xbt_thread_self_name(void) {
+   return xbt_thread_self()->name;
+}
+
+
 void 
 xbt_thread_join(xbt_thread_t thread) {
    THROW_UNIMPLEMENTED; /* FIXME */
 void 
 xbt_thread_join(xbt_thread_t thread) {
    THROW_UNIMPLEMENTED; /* FIXME */