Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Go for a thread_cancel instead of a thread_destroy since every documentation says...
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 11 Jul 2007 17:50:08 +0000 (17:50 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 11 Jul 2007 17:50:08 +0000 (17:50 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3741 48e7efb5-ca39-0410-a469-dd3cf9ba447f

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

index 84bdb797989ca9a646c54c0150395a2f6960eca7..92e8d3ae9facd408fac7aba75079c3d40d3759f2 100644 (file)
@@ -37,8 +37,8 @@ SG_BEGIN_DECL()
   XBT_PUBLIC(xbt_thread_t) xbt_thread_self(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);
   XBT_PUBLIC(xbt_thread_t) xbt_thread_self(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);
-  /* Brutally ends the life of the poor victim */
-  XBT_PUBLIC(void) xbt_thread_destroy(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_PUBLIC(void) xbt_thread_cancel(xbt_thread_t thread);
   /* suicide */
   XBT_PUBLIC(void) xbt_thread_exit(void);
   /* current thread pass control to any possible thread wanting it */
   /* suicide */
   XBT_PUBLIC(void) xbt_thread_exit(void);
   /* current thread pass control to any possible thread wanting it */
index b023fe80fc29537302d5ce510f33a093a1812e0e..2dc4aa24d3b6dfaa7e3621472174aac42223adad 100644 (file)
@@ -59,7 +59,6 @@ static void * wrapper_start_routine(void *s) {
     THROW0(system_error,errcode,"pthread_setspecific failed for xbt_self_thread_key");   
   return t->start_routine(t->param);
 }
     THROW0(system_error,errcode,"pthread_setspecific failed for xbt_self_thread_key");   
   return t->start_routine(t->param);
 }
-
 xbt_os_thread_t xbt_os_thread_create(pvoid_f_pvoid_t start_routine,
                                     void* param)  {
    int errcode;
 xbt_os_thread_t xbt_os_thread_create(pvoid_f_pvoid_t start_routine,
                                     void* param)  {
    int errcode;
@@ -98,6 +97,9 @@ xbt_os_thread_t xbt_os_thread_self(void) {
 void xbt_os_thread_yield(void) {
    sched_yield();
 }
 void xbt_os_thread_yield(void) {
    sched_yield();
 }
+void xbt_os_thread_cancel(xbt_os_thread_t t) {
+   pthread_cancel(t->t);
+}
 /****** mutex related functions ******/
 typedef struct xbt_os_mutex_ {
   /* KEEP IT IN SYNC WITH xbt_thread.c */
 /****** mutex related functions ******/
 typedef struct xbt_os_mutex_ {
   /* KEEP IT IN SYNC WITH xbt_thread.c */
@@ -301,6 +303,9 @@ void *xbt_os_thread_getparam(void) {
 void xbt_os_thread_yield(void) {
     Sleep(0);
 }
 void xbt_os_thread_yield(void) {
     Sleep(0);
 }
+void xbt_os_thread_cancel(xbt_os_thread_t t) {
+   THROW_UNIMPLEMENTED;
+}
 
 /****** mutex related functions ******/
 typedef struct xbt_os_mutex_ {
 
 /****** mutex related functions ******/
 typedef struct xbt_os_mutex_ {
index 9c6bde4530fbc882f5a48d4f720acc3677793556..dfb439a1eeceb8c486e6681d0a1632be07b87b46 100644 (file)
@@ -60,6 +60,9 @@ xbt_thread_t xbt_thread_self(void) {
 void xbt_thread_yield(void) {
    xbt_os_thread_yield();
 }
 void xbt_thread_yield(void) {
    xbt_os_thread_yield();
 }
+void xbt_thread_cancel(xbt_thread_t t) {
+   xbt_os_thread_cancel(t->os_thread);
+}
 /****** mutex related functions ******/
 struct xbt_mutex_ {
    /* KEEP IT IN SYNC WITH OS IMPLEMENTATION (both win and lin) */
 /****** mutex related functions ******/
 struct xbt_mutex_ {
    /* KEEP IT IN SYNC WITH OS IMPLEMENTATION (both win and lin) */
index ee00c07ba3cdcc3fd3e7a8981a71355cf9040e7b..bf285864412c644ac195a3356472e26c27c4533f 100644 (file)
@@ -49,13 +49,15 @@ xbt_thread_join(xbt_thread_t thread) {
 }                     
 
 void 
 }                     
 
 void 
-xbt_thread_destroy(xbt_thread_t thread) {
+xbt_thread_cancel(xbt_thread_t thread) {
    SIMIX_process_kill(thread->s_process);
    free(thread);
 }                     
 
 void xbt_thread_exit() {
    SIMIX_process_kill(thread->s_process);
    free(thread);
 }                     
 
 void xbt_thread_exit() {
-   xbt_thread_destroy(xbt_thread_self());
+   xbt_thread_t me=SIMIX_process_get_data(SIMIX_process_self());
+   SIMIX_process_kill(me->s_process);
+   free(me);
 }
 
 xbt_thread_t xbt_thread_self(void) {
 }
 
 xbt_thread_t xbt_thread_self(void) {