void EventCheck2() { VCOS_THREAD_T thread1, thread2; // Create two event group. TEST_OK("os_eventgroup_create", os_eventgroup_create ( &eventgroup, "group") ); TEST_OK("os_eventgroup_create", os_eventgroup_create ( &eventgroup2, "group2") ); TEST_OK("os_thread_start", os_thread_start( &thread1, &ThreadTwo, NULL, 1000, "ThreadOne")); TEST_OK("os_thread_start", os_thread_start( &thread2, &ThreadThree, NULL, 1000, "ThreadTwo")); // Wait for threads to start. Should really check a semaphore! TEST_OK("os_delay", os_delay(1000)); for (current_event=1;current_event<=TERM_EVENT;current_event++) { TEST_OK("os_eventgroup_signal", os_eventgroup_signal ( &eventgroup, current_event) ); // for moment same on other thread current_event2 = current_event; TEST_OK("os_eventgroup_signal", os_eventgroup_signal ( &eventgroup2, current_event2) ); TEST_OK("os_delay", os_delay(1000)); } TEST_OK("os_eventgroup_destroy", os_eventgroup_destroy ( &eventgroup ) ); }
/* ---------------------------------------------------------------------- * initialise host-side OpenMAX IL component service * -------------------------------------------------------------------- */ void vc_vchi_ilcs_init( VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections ) { int32_t success; SERVICE_CREATION_T parameters = { MAKE_FOURCC("ILCS"), // 4cc service code connections[0], // passed in fn ptrs 0, // tx fifo size (unused) 0, // tx fifo size (unused) 0, // service callback 0 }; // callback parameter memset( &vc_ilcsg, 0, sizeof(VC_ILCS_GLOBALS_T) ); // create thread semaphore for blocking os_semaphore_create( &vc_ilcsg.component_lock, OS_SEMAPHORE_TYPE_SUSPEND ); // create semaphore for protecting wait/xid structures os_semaphore_create( &vc_ilcsg.wait_sem, OS_SEMAPHORE_TYPE_SUSPEND ); // create semaphore for correct ordering of control+bulk pairs os_semaphore_create( &vc_ilcsg.send_sem, OS_SEMAPHORE_TYPE_SUSPEND ); // open 'ILCS' service success = vchi_service_open( initialise_instance, ¶meters, &vc_ilcsg.vchi_handle ); vc_assert( success == 0 ); success = os_thread_start( &vc_ilcsg.thread, vc_ilcs_task, NULL, 4000, "ILCS_HOST" ); vc_assert( success == 0 ); }
/*! *@brief GarbageCollectionStart接口回调函数 *@author zhaohm3 *@param[in] jvmti_env *@retval *@note * *@since 2014-9-15 17:58 *@attention * */ GPrivate void JNICALL JVMGarbageCollectionStart(jvmtiEnv *jvmti_env) { GCMON_PRINT_FUNC(); if (NULL == gpPerfTree && gPerfMemory != NULL) { //! 通过gPerfMemory构建性能树 gcmon_init_perf_tree(); //! 性能计数器红黑树构建好了后,随机初始化性能采样项 GASSERT(gpPerfTree != NULL); sample_init(gpPerfTree); gpThread = os_thread_create((Int32_t (JNICALL *)(void *))sample_tdoit, (void *)"OSThread "); os_thread_start(gpThread); } }
/* ---------------------------------------------------------------------- * initialise host-side OpenMAX IL component service * -------------------------------------------------------------------- */ void vc_vchi_ilcs_init( VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections ) { int32_t success; memset( &vc_ilcsg, 0, sizeof(VC_ILCS_GLOBALS_T) ); // sema_init(&vc_ilcsg.msg_prod, 0); sema_init(&vc_ilcsg.msg_cons, 1); sema_init(&vc_ilcsg.omxlog_lock, 1); vc_ilcsg.omxlog_rindex = 0; vc_ilcsg.omxlog_windex = 0; vc_ilcsg.omxlog = vmalloc(VC03_OMXLOG_MAX); memset(vc_ilcsg.omxlog, 0, VC03_OMXLOG_MAX); // create thread semaphore for blocking os_semaphore_create( &vc_ilcsg.component_lock, OS_SEMAPHORE_TYPE_SUSPEND ); os_semaphore_create( &vc_ilcsg.rxmsg_sem, OS_SEMAPHORE_TYPE_SUSPEND ); os_semaphore_obtain( &vc_ilcsg.rxmsg_sem ); // create semaphore for protecting wait/xid structures os_semaphore_create( &vc_ilcsg.wait_sem, OS_SEMAPHORE_TYPE_SUSPEND ); // open 'ILCS' service SERVICE_CREATION_T parameters = { MAKE_FOURCC("ILCS"), // 4cc service code connections[0], // passed in fn ptrs 0, // tx fifo size (unused) 0, // tx fifo size (unused) &vc_ilcs_callback, // service callback &vc_ilcsg.rxmsg_sem }; // callback parameter success = vchi_service_open( initialise_instance, ¶meters, &vc_ilcsg.vchi_handle ); assert( success == 0 ); success = os_thread_start( &vc_ilcsg.thread, vc_ilcs_task, NULL, 4000, "ILCS_HOST" ); assert( success == 0 ); }
void ThreadCheck() { VCOS_THREAD_T thread; // First create a sync semaphore TEST_OK("os_semaphore_create", os_semaphore_create(&sem1, OS_SEMAPHORE_TYPE_SUSPEND)); // and grab it TEST_OK("os_semaphore_obtain", os_semaphore_obtain(&sem1)); // Start the thread which shuold stall on the semaphore TEST_OK("os_thread_start", os_thread_start( &thread, &ThreadOne, NULL, 1000, "ThreadOne")); // Wait for thread to start for 1000 - should stall on semaphore and not change flag TEST_OK("os_delay", os_delay(1000)); // Check global data is unchanged TEST_OK("Flag = 0", flag); // release semaphore TEST_OK("os_semaphore_release", os_semaphore_release(&sem1)); // Wait for thread to continue for 100 - should be enough for it to set the flag TEST_OK("os_delay", os_delay(100)); // Check global data is changed to non-zero TEST_OK("Flag = 1", (flag == 0)); // Semaphore is currently released, so check the obtained function is correct. TEST_OK("os_semaphore_obtained - 0", os_semaphore_obtained(&sem1)) // now get the sema and test again TEST_OK("os_semaphore_obtain", os_semaphore_obtain(&sem1)); TEST_OK("os_semaphore_obtained - 1", (os_semaphore_obtained(&sem1) == 0)) TEST_OK("os_semaphore_release", os_semaphore_release(&sem1)); }
void vc_vchi_hostreq_init (VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections ) { int success, i; // record the number of connections memset( &hostreq_client, 0, sizeof(HOSTREQ_SERVICE_T) ); hostreq_client.num_connections = num_connections; success = os_semaphore_create( &hostreq_client.sema, OS_SEMAPHORE_TYPE_SUSPEND ); assert( success == 0 ); success = os_semaphore_create( &hostreq_client_message_available, OS_SEMAPHORE_TYPE_BUSY_WAIT ); assert( success == 0 ); success = os_semaphore_obtain(&hostreq_client_message_available); assert( success == 0 ); for (i=0; i<hostreq_client.num_connections; i++) { // Create a 'Client' service on the each of the connections SERVICE_CREATION_T hostreq_parameters = { HOSTREQ_NAME, // 4cc service code connections[i], // passed in fn ptrs 0, // tx fifo size (unused) 0, // tx fifo size (unused) &hostreq_client_callback, // service callback &hostreq_client_message_available }; // callback parameter success = vchi_service_open( initialise_instance, &hostreq_parameters, &hostreq_client.client_handle[i] ); assert( success == 0 ); } success = os_thread_start(&hostreq_client_task, &hostreqclient_func, NULL, 2048, "HOSTREQ task"); assert(!success); if(!success) { hostreq_client.initialised = 1; //Send a time across immediately time_t dummytime = 0; //We need to get the real time on a real host success = hostreq_send_command(VC_HOSTREQ_TIME, &dummytime, sizeof(dummytime)); assert( success == 0 ); } }
void EventCheck() { VCOS_THREAD_T thread; // Create one event group. TEST_OK("os_eventgroup_create", os_eventgroup_create ( &eventgroup, "group") ); TEST_OK("os_thread_start", os_thread_start( &thread, &ThreadTwo, NULL, 1000, "ThreadOne")); // Wait for thread to start. Should really check a semaphore! TEST_OK("os_delay", os_delay(1000)); for (current_event=1;current_event<=TERM_EVENT;current_event++) { TEST_OK("os_eventgroup_signal", os_eventgroup_signal ( &eventgroup, current_event) ); TEST_OK("os_delay", os_delay(1000)); } TEST_OK("os_eventgroup_destroy", os_eventgroup_destroy ( &eventgroup ) ); }
/****************************************************************************** NAME vc_vchi_cec_init SYNOPSIS void vc_vchi_cec_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections ) FUNCTION Initialise the CEC service for use. A negative return value indicates failure (which may mean it has not been started on VideoCore). RETURNS int ******************************************************************************/ VCHPRE_ void VCHPOST_ vc_vchi_cec_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections ) { int32_t success = -1; uint32_t i; // record the number of connections memset( &cecservice_client, 0, sizeof(CECSERVICE_HOST_STATE_T) ); cecservice_client.num_connections = num_connections; success = os_semaphore_create( &cecservice_client.sema, OS_SEMAPHORE_TYPE_SUSPEND ); vcos_assert( success == 0 ); success = os_semaphore_create( &cecservice_message_available_semaphore, OS_SEMAPHORE_TYPE_BUSY_WAIT ); vcos_assert( success == 0 ); success = os_semaphore_obtain( &cecservice_message_available_semaphore ); vcos_assert( success == 0 ); success = os_semaphore_create( &cecservice_notify_available_semaphore, OS_SEMAPHORE_TYPE_SUSPEND ); vcos_assert( success == 0 ); success = os_semaphore_obtain( &cecservice_notify_available_semaphore ); vcos_assert( success == 0 ); cecservice_client.topology = os_malloc(sizeof(VC_CEC_TOPOLOGY_T), 16, "CEC topology"); vcos_assert(cecservice_client.topology); for (i=0; i < cecservice_client.num_connections; i++) { // Create a 'Client' service on the each of the connections SERVICE_CREATION_T cecservice_parameters = { CECSERVICE_CLIENT_NAME, // 4cc service code connections[i], // passed in fn ptrs 0, // tx fifo size (unused) 0, // tx fifo size (unused) &cecservice_client_callback,// service callback &cecservice_message_available_semaphore, // callback parameter VC_FALSE, // want_unaligned_bulk_rx VC_FALSE, // want_unaligned_bulk_tx VC_FALSE, // want_crc }; SERVICE_CREATION_T cecservice_parameters2 = { CECSERVICE_NOTIFY_NAME, // 4cc service code connections[i], // passed in fn ptrs 0, // tx fifo size (unused) 0, // tx fifo size (unused) &cecservice_notify_callback,// service callback &cecservice_notify_available_semaphore, // callback parameter VC_FALSE, // want_unaligned_bulk_rx VC_FALSE, // want_unaligned_bulk_tx VC_FALSE, // want_crc }; //Create the client to normal CEC service success = vchi_service_open( initialise_instance, &cecservice_parameters, &cecservice_client.client_handle[i] ); vcos_assert( success == 0 ); //Create the client to the async CEC service (any CEC related notifications) success = vchi_service_open( initialise_instance, &cecservice_parameters2, &cecservice_client.notify_handle[i] ); vcos_assert( success == 0 ); } //Create the notifier task success = os_thread_start(&cecservice_notify_task, cecservice_notify_func, &cecservice_client, 2048, "CEC Notify"); vcos_assert( success == 0 ); cecservice_client.initialised = 1; }