コード例 #1
0
ファイル: test12.mutatee.c プロジェクト: vishalmistry/imitate
void *thread_main8(void *arg)
{
  /*  The mutator will patch in messaging primitives to signal events at mutex creation,
      deletion, locking and unlocking.  Thus far, we are only considering reporting of events
      so actual contention is meaningless */
  Lock_t newmutex;
  if (!createLock(&newmutex)) {
     fprintf(stderr, "%s[%d]:  createLock failed\n", __FILE__, __LINE__);
     return NULL;
  }
  sleep_ms(100);
  if (!lockLock(&newmutex)) {
     fprintf(stderr, "%s[%d]:  lockLock failed\n", __FILE__, __LINE__);
     return NULL;
  }
  sleep_ms(100);
  if (!unlockLock(&newmutex)) {
     fprintf(stderr, "%s[%d]:  unlockLock failed\n", __FILE__, __LINE__);
     return NULL;
  }
  sleep_ms(100); 
  if (!destroyLock(&newmutex)) {
     fprintf(stderr, "%s[%d]:  destroyLock failed\n", __FILE__, __LINE__);
     return NULL;
  }

  sleep(1);
  return NULL;
}
コード例 #2
0
ファイル: exceptions.c プロジェクト: ahua/java
/*
 * If the current method is synchronized, unlock it
 */
static void unlockIfSynchronized() {
    int flags = getInt(method, ENTRY_FLAGS);
    if (flags && ACC_SYNCHRONIZED) {
        Ref lock = getRef(frame, OBJECT_LOCK);
        if (lock != NULL) { unlockLock(lock); }
    }
}
コード例 #3
0
ファイル: monitor.c プロジェクト: ahua/java
/*
 * Execute the MONITOREXIT instruction
 */
void op_monitorexit() {
    // assume the current thread owns the monitor
    // assume lock was created when monitorenter was called
    Ref object = popRef();
    Ref lock = getRef(object, OBJECT_LOCK);
    if (lock == NULL) {
        printf("Illegal State, no lock found\n");
        debugTrace();
        exit(1);
    }
    unlockLock(lock);
    pc++;
}
コード例 #4
0
ファイル: test12.mutatee.c プロジェクト: vishalmistry/imitate
void func6_1()
{
#if defined(os_none)
  createLock(&test6lock);
  lockLock(&test6lock); 
  assert (NULL != createThreads(TEST6_THREADS, thread_main6, test6_threads));

  unlockLock(&test6lock); 
  mutateeIdle = 1;
  while (mutateeIdle) {}
#else
#endif
}
コード例 #5
0
ファイル: test12.mutatee.c プロジェクト: vishalmistry/imitate
void *thread_main6(void *arg)
{
  int x, i;
  lockLock(&test6lock); 
  x = 0;
  for (i = 0; i < 0xf; ++i) {
    x = x + i;
  }

  unlockLock(&test6lock); 
  dprintf("%s[%d]:  %lu exiting...\n", __FILE__, __LINE__, (unsigned long) pthread_self());
  return (void *) x;
}
コード例 #6
0
ファイル: test12.mutatee.c プロジェクト: vishalmistry/imitate
void func5_1()
{
#if defined(os_none)
  createLock(&test5lock);
  lockLock(&test5lock); 
  assert (NULL != createThreads(TEST5_THREADS, thread_main5, test5_threads));

  sleep_ms(999);
  unlockLock(&test5lock); 
  mutateeIdle = 1;
  while (mutateeIdle) {}
#else
#endif
}
コード例 #7
0
ファイル: test12.mutatee.c プロジェクト: vishalmistry/imitate
void *thread_main3(void *arg)
{
  int x, i;
  lockLock(&test3lock);
  x = 0;

  for (i = 0; i < 0xffff; ++i) {
    x = x + i;
  }
  /*fprintf(stderr, "%s[%d]:  PTHREAD_DESTROY\n", __FILE__, __LINE__); */

  unlockLock(&test3lock);
  dprintf("%s[%d]:  %lu exiting...\n", __FILE__, __LINE__, (unsigned long) pthread_self());
  return (void *) x;
}
コード例 #8
0
ファイル: test12.mutatee.c プロジェクト: vishalmistry/imitate
void func3_1()
{

  createLock(&test3lock);
  mutateeIdle = 1;

  lockLock(&test3lock);
  assert (NULL != createThreads(TEST3_THREADS, thread_main3, test3_threads));

  sleep_ms(999);
  unlockLock(&test3lock);
  dprintf("%s[%d]:  func3_1\n", __FILE__, __LINE__);
  while (mutateeIdle) {}

  dprintf("%s[%d]:  leaving func3_1\n", __FILE__, __LINE__);
}
コード例 #9
0
ファイル: test12.mutatee.c プロジェクト: vishalmistry/imitate
void func4_1()
{
/*
#if defined(os_linux) && defined(arch_x86)
#else
*/
  dprintf("%s[%d]:  welcome to func4_1\n", __FILE__, __LINE__);
  createLock(&test4lock);


  lockLock(&test4lock); 
   
  assert (NULL != createThreads(TEST3_THREADS, thread_main4, test4_threads));

  unlockLock(&test4lock); 
  mutateeIdle = 1;
  while (mutateeIdle) {}
/*
#endif
*/

}