コード例 #1
0
static int simple_pingpong(void)
{
   static VCOS_THREAD_T server, clients[N_CLIENTS];
   unsigned long sent, received = 0;
   void *psent = &sent;
   int i;
   VCOS_STATUS_T st;
   VCOS_MSG_ENDPOINT_T self;

   st = vcos_msgq_endpoint_create(&self,"test");

   st = vcos_thread_create(&server, "server", NULL, simple_server, NULL);

   for (i=0; i<N_CLIENTS; i++)
   {
      st = vcos_thread_create(&clients[i], "client", NULL, simple_client, NULL);
   }

   // wait for the clients to quit
   for (i=0; i<N_CLIENTS; i++)
   {
      unsigned long rx;
      void *prx = &rx;
      vcos_thread_join(&clients[i],prx);
      received += rx;
   }

   // tell the server to quit
   {
      VCOS_MSG_T quit;
      VCOS_MSGQUEUE_T *serverq = vcos_msgq_find("server");

      vcos_assert(serverq != NULL);

      vcos_log("client: sending quit");
      vcos_msg_sendwait(serverq, VCOS_MSG_N_QUIT, &quit);
      vcos_thread_join(&server,psent);
   }

   vcos_msgq_endpoint_delete(&self);

   if (sent == received)
      return 1;
   else
   {
      vcos_log("bad: sent %d, received %d", sent, received);
      return 0;
   }
}
コード例 #2
0
ファイル: vc_vchi_dispmanx.c プロジェクト: UIKit0/userland
/***********************************************************
 * Name: vc_dispmanx_stop
 *
 * Arguments:
 *       -
 *
 * Description: Stops the Host side part of dispmanx
 *
 * Returns: -
 *
 ***********************************************************/
VCHPRE_ void VCHPOST_ vc_dispmanx_stop( void ) {
   // Wait for the current lock-holder to finish before zapping dispmanx.
   //TODO: kill the notifier task
   void *dummy;
   uint32_t i;

   if (!dispmanx_client.initialised)
      return;

   lock_obtain();
   for (i=0; i<dispmanx_client.num_connections; i++) {
      int32_t result;
      result = vchi_service_close(dispmanx_client.client_handle[i]);
      vcos_assert( result == 0 );
      result = vchi_service_close(dispmanx_client.notify_handle[i]);
      vcos_assert( result == 0 );
   }
   lock_release();
   dispmanx_client.initialised = 0;

   vcos_event_signal(&dispmanx_notify_available_event); 
   vcos_thread_join(&dispmanx_notify_task, &dummy);
   vcos_mutex_delete(&dispmanx_client.lock);
   vcos_event_delete(&dispmanx_message_available_event);
   vcos_event_delete(&dispmanx_notify_available_event);
}
コード例 #3
0
		~CThreadT()
		{
			vcos_event_flags_set(&m_EventFlags, s_nTerminationFlag, VCOS_OR);
			void* pData;
			vcos_thread_join(&m_Thread, &pData);
			vcos_event_flags_delete(&m_EventFlags);
			vcos_event_delete(&m_InitializedEvent);
		}
コード例 #4
0
ファイル: RaspiTex.c プロジェクト: JimmyC543/userland
/* Stops the rendering loop and destroys MMAL resources
 * @param state  Pointer to the GL preview state.
 */
void raspitex_stop(RASPITEX_STATE *state)
{
    if (! state->preview_stop)
    {
        vcos_log_trace("Stopping GL preview");
        state->preview_stop = 1;
        vcos_thread_join(&state->preview_thread, NULL);
    }
}
コード例 #5
0
ファイル: eventgroup.c プロジェクト: cgjones/brcm_usrlib_dag
static void waiter_deinit(WAITER_T *waiter, int *passed)
{
   waiter->quit = 1;
   vcos_semaphore_post(&waiter->go);

   vcos_thread_join(&waiter->thread,NULL);

   vcos_semaphore_delete(&waiter->go);
   vcos_semaphore_delete(&waiter->done);
}
コード例 #6
0
static void guard_deinit(GUARD_T *guard, int *passed)
{
   guard->quit = 1;
   vcos_semaphore_post(&guard->go);

   vcos_thread_join(&guard->thread,0);

   vcos_semaphore_delete(&guard->go);
   vcos_semaphore_delete(&guard->done);
   vcos_event_flags_delete(&guard->event);
}
コード例 #7
0
void khrn_worker_term(void)
{
   vcos_assert(inited);
   vcos_assert(khrn_worker_msg.done_it == khrn_worker_msg.post); /* should have called khrn_worker_wait or equivalent before this */
   vcos_assert(khrn_worker_msg.cleanup == khrn_worker_msg.post);

#ifdef KHRN_WORKER_USE_LLAT
   khrn_llat_unregister(llat_i);
#else
   exit_thread = true;
   vcos_event_signal(&event);
   vcos_thread_join(&thread, NULL);

   vcos_event_delete(&event);
#endif

   inited = false;
}
コード例 #8
0
ファイル: svp.c プロジェクト: 4leavedclover/userland
/* Stop SVP. Stops worker thread + disables MMAL connection. */
void svp_stop(SVP_T *svp)
{
   vcos_timer_cancel(&svp->wd_timer);
   vcos_timer_cancel(&svp->timer);

   /* Stop worker thread */
   if (svp->created & SVP_CREATED_THREAD)
   {
      svp_set_stop(svp, SVP_STOP_USER);
      vcos_semaphore_post(&svp->sema);
      vcos_thread_join(&svp->thread, NULL);
      svp->created &= ~SVP_CREATED_THREAD;
   }

   if (svp->connection)
   {
      mmal_connection_disable(svp->connection);
   }

   mmal_port_disable(svp->video_output);
}
コード例 #9
0
static void graph_stop_worker_thread(MMAL_GRAPH_PRIVATE_T *graph)
{
   graph->stop_thread = MMAL_TRUE;
   vcos_semaphore_post(&graph->sema);
   vcos_thread_join(&graph->thread, NULL);
}
コード例 #10
0
ファイル: mmalplay.c プロジェクト: ms-iot/userland
int main(int argc, const char **argv)
{
   VCOS_THREAD_ATTR_T attrs;
   int i;

   vcos_init();
   signal(SIGINT, test_signal_handler);

   /* coverity[tainted_data] Ignore unnecessary warning about an attacker
    * being able to pass an arbitrarily long "-vvvvv..." argument */
   if (test_parse_cmdline(argc, argv))
      return -1;

   if (verbosity--)
   {
      static char value[512];
      const char *levels[] = {"warn", "info", "trace"};
      char *env = getenv("VC_LOGLEVEL");
      if (verbosity >= MMAL_COUNTOF(levels)) verbosity = MMAL_COUNTOF(levels) - 1;
      snprintf(value, sizeof(value)-1, "mmalplay:%s,mmal:%s,%s",
               levels[verbosity], levels[verbosity], env ? env : "");
#ifdef WIN32
      _putenv("VC_LOGLEVEL", value, 1);
#else
      setenv("VC_LOGLEVEL", value, 1);
#endif
   }

   vcos_log_register("mmalplay", VCOS_LOG_CATEGORY);
   LOG_INFO("MMAL Video Playback Test App");

   vcos_thread_attr_init(&attrs);
   for (i = 0; i < play_info_count; i++)
   {
      const char *uri = play_info[i].uri;

      memcpy(play_info[i].name, THREAD_PREFIX, sizeof(THREAD_PREFIX));
      if (strlen(uri) >= URI_FOR_THREAD_NAME_MAX)
         uri += strlen(uri) - URI_FOR_THREAD_NAME_MAX;
      strncat(play_info[i].name, uri, URI_FOR_THREAD_NAME_MAX);

      vcos_mutex_create(&play_info[i].lock, "mmalplay");
      play_info[i].options.render_layer = i;

      if (vcos_thread_create(&play_info[i].thread, play_info[i].name, &attrs, mmal_playback, &play_info[i]) != VCOS_SUCCESS)
      {
         LOG_ERROR("Thread creation failure for URI %s", play_info[i].uri);
         return -2;
      }
   }

   if (sleepy_time != 0)
   {
#ifdef WIN32
      Sleep(sleepy_time);
#else
      sleep(sleepy_time);
#endif
      for (i = 0; i < play_info_count; i++)
      {
         vcos_mutex_lock(&play_info[i].lock);
         if (play_info[i].ctx)
            mmalplay_stop(play_info[i].ctx);
         vcos_mutex_unlock(&play_info[i].lock);
      }
   }

   LOG_TRACE("Waiting for threads to terminate");
   for (i = 0; i < play_info_count; i++)
   {
      vcos_thread_join(&play_info[i].thread, NULL);
      LOG_TRACE("Joined thread %d (%i)", i, play_info[i].status);
   }

   LOG_TRACE("Completed");

   /* Check for errors */
   for (i = 0; i < play_info_count; i++)
   {
      if (!play_info[i].status)
         continue;

      LOG_ERROR("Playback of %s failed (%i, %s)", play_info[i].uri,
                play_info[i].status,
                mmal_status_to_string(play_info[i].status));
      fprintf(stderr, "playback of %s failed (%i, %s)\n", play_info[i].uri,
              play_info[i].status,
              mmal_status_to_string(play_info[i].status));
      return play_info[i].status;
   }

   return 0;
}