Lines Matching refs:this

129 static void nct_exit_and_cleanup(struct te_status_t *this);
130 static struct threads_table_el *ttable_get_element(struct te_status_t *this, int index);
135 static void abort_tail(struct te_status_t *this, int this_th_nbr) in abort_tail() argument
137 struct threads_table_el *tt_el = ttable_get_element(this, this_th_nbr); in abort_tail()
146 nct_exit_and_cleanup(this); in abort_tail()
157 static void nct_wait_until_allowed(struct te_status_t *this, int this_th_nbr) in nct_wait_until_allowed() argument
159 struct threads_table_el *tt_el = ttable_get_element(this, this_th_nbr); in nct_wait_until_allowed()
168 while (this_th_nbr != this->currently_allowed_thread) { in nct_wait_until_allowed()
169 pthread_cond_wait(&this->cond_threads, &this->mtx_threads); in nct_wait_until_allowed()
172 abort_tail(this, this_th_nbr); in nct_wait_until_allowed()
189 static void nct_let_run(struct te_status_t *this, int next_allowed_th) in nct_let_run() argument
192 struct threads_table_el *tt_el = ttable_get_element(this, next_allowed_th); in nct_let_run()
200 this->currently_allowed_thread = next_allowed_th; in nct_let_run()
209 NSI_SAFE_CALL(pthread_cond_broadcast(&this->cond_threads)); in nct_let_run()
215 static void nct_exit_and_cleanup(struct te_status_t *this) in nct_exit_and_cleanup() argument
220 NSI_SAFE_CALL(pthread_mutex_unlock(&this->mtx_threads)); in nct_exit_and_cleanup()
245 struct te_status_t *this = (struct te_status_t *)this_arg; in nct_swap_threads() local
246 int this_th_nbr = this->currently_allowed_thread; in nct_swap_threads()
248 nct_let_run(this, next_allowed_thread_nbr); in nct_swap_threads()
253 nct_exit_and_cleanup(this); in nct_swap_threads()
256 struct threads_table_el *tt_el = ttable_get_element(this, this_th_nbr); in nct_swap_threads()
263 abort_tail(this, this_th_nbr); in nct_swap_threads()
265 nct_wait_until_allowed(this, this_th_nbr); in nct_swap_threads()
282 struct te_status_t *this = (struct te_status_t *)this_arg; in nct_first_thread_start() local
284 nct_let_run(this, next_allowed_thread_nbr); in nct_first_thread_start()
287 nct_exit_and_cleanup(this); in nct_first_thread_start()
296 struct te_status_t *this = element->ts_status; in nct_cleanup_handler() local
305 if (!this->terminate) { in nct_cleanup_handler()
314 NSI_SAFE_CALL(pthread_mutex_unlock(&this->mtx_threads)); in nct_cleanup_handler()
328 struct te_status_t *this = tt_el->ts_status; in nct_thread_starter() local
341 NSI_SAFE_CALL(pthread_mutex_lock(&this->mtx_threads)); in nct_thread_starter()
347 if (!this->threads_table || this->terminate) { in nct_thread_starter()
364 nct_wait_until_allowed(this, thread_idx); in nct_thread_starter()
366 this->fptr(tt_el->payload); in nct_thread_starter()
387 static struct threads_table_el *ttable_get_element(struct te_status_t *this, int index) in ttable_get_element() argument
389 struct threads_table_el *threads_table = this->threads_table; in ttable_get_element()
391 if (index >= this->threads_table_size) { /* LCOV_EXCL_BR_LINE */ in ttable_get_element()
394 index, this->threads_table_size); /* LCOV_EXCL_LINE */ in ttable_get_element()
406 static int ttable_get_empty_slot(struct te_status_t *this) in ttable_get_empty_slot() argument
408 struct threads_table_el *tt_el = this->threads_table; in ttable_get_empty_slot()
410 for (int i = 0; i < this->threads_table_size; i++, tt_el = tt_el->next) { in ttable_get_empty_slot()
431 tt_el = ttable_get_element(this, this->threads_table_size-1); in ttable_get_empty_slot()
434 this->threads_table_size += NCT_ALLOC_CHUNK_SIZE; in ttable_get_empty_slot()
443 return this->threads_table_size - NCT_ALLOC_CHUNK_SIZE; in ttable_get_empty_slot()
462 struct te_status_t *this = (struct te_status_t *)this_arg; in nct_new_thread() local
466 t_slot = ttable_get_empty_slot(this); in nct_new_thread()
467 tt_el = ttable_get_element(this, t_slot); in nct_new_thread()
471 tt_el->thead_cnt = this->thread_create_count++; in nct_new_thread()
473 tt_el->ts_status = this; in nct_new_thread()
503 struct te_status_t *this; in nct_init() local
512 this = calloc(1, sizeof(struct te_status_t)); in nct_init()
513 if (this == NULL) { /* LCOV_EXCL_BR_LINE */ in nct_init()
517 this->fptr = fptr; in nct_init()
518 this->thread_create_count = 0; in nct_init()
519 this->currently_allowed_thread = -1; in nct_init()
521 NSI_SAFE_CALL(pthread_cond_init(&this->cond_threads, NULL)); in nct_init()
522 NSI_SAFE_CALL(pthread_mutex_init(&this->mtx_threads, NULL)); in nct_init()
524 this->threads_table = calloc(NCT_ALLOC_CHUNK_SIZE, in nct_init()
526 if (this->threads_table == NULL) { /* LCOV_EXCL_BR_LINE */ in nct_init()
530 this->threads_table_size = NCT_ALLOC_CHUNK_SIZE; in nct_init()
533 this->threads_table[i].next = &this->threads_table[i+1]; in nct_init()
535 this->threads_table[NCT_ALLOC_CHUNK_SIZE - 1].next = NULL; in nct_init()
537 NSI_SAFE_CALL(pthread_mutex_lock(&this->mtx_threads)); in nct_init()
539 return (void *)this; in nct_init()
557 struct te_status_t *this = (struct te_status_t *)this_arg; in nct_clean_up() local
559 if (!this || !this->threads_table) { /* LCOV_EXCL_BR_LINE */ in nct_clean_up()
563 this->terminate = true; in nct_clean_up()
566 struct threads_table_el *tt_el = this->threads_table; in nct_clean_up()
568 for (int i = 0; i < this->threads_table_size; i++, tt_el = tt_el->next) { in nct_clean_up()
609 struct te_status_t *this = (struct te_status_t *)this_arg; in nct_abort_thread() local
610 struct threads_table_el *tt_el = ttable_get_element(this, thread_idx); in nct_abort_thread()
612 if (thread_idx == this->currently_allowed_thread) { in nct_abort_thread()
646 struct te_status_t *this = (struct te_status_t *)this_arg; in nct_get_unique_thread_id() local
647 struct threads_table_el *tt_el = ttable_get_element(this, thread_idx); in nct_get_unique_thread_id()
654 struct te_status_t *this = (struct te_status_t *)this_arg; in nct_thread_name_set() local
655 struct threads_table_el *tt_el = ttable_get_element(this, thread_idx); in nct_thread_name_set()