Esempio n. 1
0
/**
 * Notifies one thread waiting on the monitor.
 *
 * Only single thread waiting on the
 * object's monitor is waked up.
 * Nothing happens if no threads are waiting on the monitor.
 *
 * @param[in] monitor object where monitor is located
 * @sa java.lang.Object.notify() 
 */
IDATA VMCALL jthread_monitor_notify(jobject monitor)
{
    assert(monitor);

    hythread_suspend_disable();
    hythread_thin_monitor_t *lockword = vm_object_get_lockword_addr(monitor);
    IDATA status = hythread_thin_monitor_notify(lockword);
    hythread_suspend_enable();

    return status;
} // jthread_monitor_notify
Esempio n. 2
0
int start_proc(void *args)
{
    hythread_thin_monitor_t *lock_p = (hythread_thin_monitor_t*)((void**)args)[0];
    hythread_thin_monitor_t *monitor_p = (hythread_thin_monitor_t*)((void**)args)[1];
    IDATA *ret =  (IDATA*)&(((void**)args)[2]);
    IDATA status;

    // wait to start
    hythread_suspend_disable();

    status = hythread_thin_monitor_enter(monitor_p);
    if (status != TM_ERROR_NONE) {
        hythread_suspend_enable();
        tf_assert_same(status, TM_ERROR_NONE);
    }

    // notify main thread about thread start
    status = hythread_thin_monitor_enter(lock_p);
    if (status != TM_ERROR_NONE) {
        hythread_suspend_enable();
        tf_assert_same(status, TM_ERROR_NONE);
    }
    started_thread_count++;
    status = hythread_thin_monitor_notify(lock_p);
    if (status != TM_ERROR_NONE) {
        hythread_suspend_enable();
        tf_assert_same(status, TM_ERROR_NONE);
    }
    status = hythread_thin_monitor_exit(lock_p);
    if (status != TM_ERROR_NONE) {
        hythread_suspend_enable();
        tf_assert_same(status, TM_ERROR_NONE);
    }

    // fall to infinite wait
    status = hythread_thin_monitor_wait(monitor_p);
    if (status != TM_ERROR_NONE) {
        hythread_suspend_enable();
        tf_assert_same(status, TM_ERROR_NONE);
    }

    (*ret)++;

    status = hythread_thin_monitor_exit(monitor_p);
    if (status != TM_ERROR_NONE) {
        hythread_suspend_enable();
        tf_assert_same(status, TM_ERROR_NONE);
    }
    hythread_suspend_enable();

    return 0;
}