/** * Create a new OS thread. * * The created thread is attached to the threading library.<br> * <br> * Unlike POSIX, this doesn't require an attributes structure. * Instead, any interesting attributes (e.g. stacksize) are * passed in with the arguments. * * @param[out] ret_thread a pointer to a hythread_t which will point to the thread (if successfully created) * @param[in] stacksize the size of the new thread's stack (bytes)<br> * 0 indicates use default size * @param[in] priority priorities range from HYTHREAD_PRIORITY_MIN to HYTHREAD_PRIORITY_MAX (inclusive) * @param[in] suspend set to non-zero to create the thread in a suspended state. * @param[in] func pointer to the function which the thread will run * @param[in] data a value to pass to the entrypoint function * * @return 0 on success or negative value on failure * * @see hythread_exit, hythread_resume */ IDATA VMCALL hythread_create(hythread_t *handle, UDATA stacksize, UDATA priority, UDATA suspend, hythread_entrypoint_t func, void *data) { hythread_t thread = (hythread_t)calloc(1, hythread_get_struct_size()); thread->need_to_free = 1; assert(thread); #ifdef ORDER ((hythread_t)thread)->p_tid = hythread_self()->thread_id; hythread_self()->thread_create_count++; ((hythread_t)thread)->p_count = hythread_self()->thread_create_count; #endif if (handle) { *handle = thread; } return hythread_create_ex(thread, NULL, stacksize, priority, NULL, func, data); }
void tested_os_threads_run(hythread_entrypoint_t run_method_param){ tested_thread_sturct_t *tts; IDATA status; tested_threads_init(TTS_INIT_COMMON_MONITOR); reset_tested_thread_iterator(&tts); while(next_tested_thread(&tts)){ // Create thread tts->native_thread = (hythread_t)calloc(1, sizeof(struct VM_thread)); tf_assert_v(tts->native_thread != NULL); tts->native_thread->java_status = TM_STATUS_ALLOCATED; status = hythread_create_ex(tts->native_thread, NULL, 0, 0, NULL, run_method_param, tts); tf_assert_v(status == TM_ERROR_NONE); tested_thread_wait_started(tts); } }