Ejemplo n.º 1
0
/* 
 * Terminate the calling thread (running) 
 * Run the next ready thread 
 */
void t_terminate(){
	if(ready_0 == NULL && ready_1 == NULL){
		t_shutdown();
	}else{
		remove_running();
		if(deq())
			setcontext(running->thread_context);
	}
}
int main(void) 
{
   int i;

   t_init();

   t_create(producer, 1, 1);
   t_create(producer, 3, 1);
   t_create(consumer, 2, 1);

   t_yield();

   t_shutdown();

   return 0;
}
Ejemplo n.º 3
0
kii_socket_code_t socket_close_cb(kii_socket_context_t* socket_context)
{
    context_t* ctx = (context_t*)socket_context->app_context;
#if CONNECT_SSL
    if (ctx->ssl != NULL)
    {
        SSL_shutdown(ctx->ssl);
    }
    if (ctx->ssl_ctx != NULL)
    {
        SSL_ctx_free(ctx->ssl_ctx);
    }
#endif
    if (ctx->sock > 0)
    {
        t_shutdown(handle, ctx->sock);
    }
    return KII_SOCKETC_OK;
}
int main(void) {

   int i, k = 1;

   t_init();

   t_create(function, 1, 1);
   printf("This is main()...\n");
   t_create(function, 2, 1);
   printf("This is main()...\n");
   t_create(function, 3, 1);

   for(i = 0; i < 5000; i++) {
      printf("This is main(%d)...\n", i);
   }

   printf("Begin shutdown...\n");
   t_shutdown();
   printf("Done with shutdown...\n");

   return 0;
}
Ejemplo n.º 5
0
int main(void)
{
   int i;

   t_init();
   t_create(function, 1, 1);
   printf("This is main(1)...\n");
   t_create(function, 2, 1);
   printf("This is main(2)...\n");
   t_create(function, 3, 1);

  for (i = 0; i < 4; i++) {
    printf("This is main(3)[%d]...\n", i);
    t_yield();
  }

   printf("Begin shutdown...\n");
   t_shutdown();
   printf("Done with shutdown...\n");

   return 0;
}