• Home
  • Raw
  • Download

Lines Matching refs:thd

57 static void thd_entry_event_signal(struct ThdEntry *thd)  in thd_entry_event_signal()  argument
63 ret = write(thd->eventfd, &e, sizeof(e)); in thd_entry_event_signal()
67 static int thd_entry_event_wait(struct ThdEntry *thd, pthread_mutex_t *mutex, in thd_entry_event_wait() argument
76 pfd[0].fd = thd->eventfd; in thd_entry_event_wait()
80 pfd[2].fd = thread_pool_get_poll_fd(thd->pdata->pool); in thd_entry_event_wait()
92 ret = read(thd->eventfd, &e, sizeof(e)); in thd_entry_event_wait()
415 static ssize_t send_data(struct DevEntry *dev, struct ThdEntry *thd, size_t len) in send_data() argument
417 struct parser_pdata *pdata = thd->pdata; in send_data()
418 bool demux = server_demux && dev->sample_size != thd->sample_size; in send_data()
421 len = (len / dev->sample_size) * thd->sample_size; in send_data()
422 if (len > thd->nb) in send_data()
423 len = thd->nb; in send_data()
427 if (thd->new_client) { in send_data()
430 uint32_t *mask = demux ? thd->mask : dev->mask; in send_data()
443 thd->new_client = false; in send_data()
454 .mask = thd->mask, in send_data()
461 static ssize_t receive_data(struct DevEntry *dev, struct ThdEntry *thd) in receive_data() argument
463 struct parser_pdata *pdata = thd->pdata; in receive_data()
466 if (thd->new_client) { in receive_data()
467 print_value(thd->pdata, 0); in receive_data()
468 thd->new_client = false; in receive_data()
471 if (dev->sample_size == thd->sample_size) { in receive_data()
475 if (thd->nb < len) in receive_data()
476 len = thd->nb; in receive_data()
485 .nb_bytes = thd->nb, in receive_data()
486 .mask = thd->mask, in receive_data()
513 static void signal_thread(struct ThdEntry *thd, ssize_t ret) in signal_thread() argument
515 thd->err = ret; in signal_thread()
516 thd->nb = 0; in signal_thread()
517 thd->active = false; in signal_thread()
518 thd_entry_event_signal(thd); in signal_thread()
524 struct ThdEntry *thd, *next_thd; in rw_thd() local
548 SLIST_FOREACH(thd, &entry->thdlist_head, dev_list_entry) { in rw_thd()
550 entry->mask[i] |= thd->mask[i]; in rw_thd()
552 if (thd->samples_count > samples_count) in rw_thd()
553 samples_count = thd->samples_count; in rw_thd()
582 SLIST_FOREACH(thd, &entry->thdlist_head, dev_list_entry) { in rw_thd()
583 if (thd->wait_for_open) { in rw_thd()
584 thd->wait_for_open = false; in rw_thd()
585 signal_thread(thd, 0); in rw_thd()
601 SLIST_FOREACH(thd, &entry->thdlist_head, dev_list_entry) { in rw_thd()
602 thd->active = !thd->err && thd->nb >= sample_size; in rw_thd()
603 if (mask_updated && thd->active) in rw_thd()
604 signal_thread(thd, thd->nb); in rw_thd()
606 if (thd->is_writer) in rw_thd()
607 has_writers |= thd->active; in rw_thd()
609 has_readers |= thd->active; in rw_thd()
654 for (thd = SLIST_FIRST(&entry->thdlist_head); in rw_thd()
655 thd; thd = next_thd) { in rw_thd()
656 next_thd = SLIST_NEXT(thd, dev_list_entry); in rw_thd()
658 if (!thd->active || thd->is_writer) in rw_thd()
661 ret = send_data(entry, thd, nb_bytes); in rw_thd()
663 thd->nb -= ret; in rw_thd()
665 if (ret < 0 || thd->nb < sample_size) in rw_thd()
666 signal_thread(thd, (ret < 0) ? in rw_thd()
667 ret : thd->nb); in rw_thd()
682 for (thd = SLIST_FIRST(&entry->thdlist_head); in rw_thd()
683 thd; thd = next_thd) { in rw_thd()
684 next_thd = SLIST_NEXT(thd, dev_list_entry); in rw_thd()
686 if (!thd->active || !thd->is_writer) in rw_thd()
689 ret = receive_data(entry, thd); in rw_thd()
691 thd->nb -= ret; in rw_thd()
697 signal_thread(thd, ret); in rw_thd()
713 for (thd = SLIST_FIRST(&entry->thdlist_head); in rw_thd()
714 thd; thd = next_thd) { in rw_thd()
715 next_thd = SLIST_NEXT(thd, dev_list_entry); in rw_thd()
716 if (thd->active && thd->is_writer && in rw_thd()
717 thd->nb < sample_size) in rw_thd()
718 signal_thread(thd, thd->nb); in rw_thd()
726 for (thd = SLIST_FIRST(&entry->thdlist_head); thd; thd = next_thd) { in rw_thd()
727 next_thd = SLIST_NEXT(thd, dev_list_entry); in rw_thd()
728 SLIST_REMOVE(&entry->thdlist_head, thd, ThdEntry, dev_list_entry); in rw_thd()
729 thd->wait_for_open = false; in rw_thd()
730 signal_thread(thd, ret); in rw_thd()
769 struct ThdEntry *thd; in rw_buffer() local
775 thd = parser_lookup_thd_entry(pdata, dev); in rw_buffer()
776 if (!thd) in rw_buffer()
779 entry = thd->entry; in rw_buffer()
790 if (thd->nb) { in rw_buffer()
795 thd->new_client = true; in rw_buffer()
796 thd->nb = nb; in rw_buffer()
797 thd->err = 0; in rw_buffer()
798 thd->is_writer = is_write; in rw_buffer()
799 thd->active = true; in rw_buffer()
804 while (thd->active) { in rw_buffer()
805 ret = thd_entry_event_wait(thd, &entry->thdlist_lock, pdata->fd_in); in rw_buffer()
810 ret = thd->err; in rw_buffer()
814 print_value(thd->pdata, 0); in rw_buffer()
877 struct ThdEntry *thd; in open_dev_helper() local
894 thd = zalloc(sizeof(*thd)); in open_dev_helper()
895 if (!thd) in open_dev_helper()
898 thd->wait_for_open = true; in open_dev_helper()
899 thd->mask = words; in open_dev_helper()
900 thd->nb = 0; in open_dev_helper()
901 thd->samples_count = samples_count; in open_dev_helper()
902 thd->sample_size = iio_device_get_sample_size_mask(dev, words, len); in open_dev_helper()
903 thd->pdata = pdata; in open_dev_helper()
904 thd->dev = dev; in open_dev_helper()
905 thd->eventfd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK); in open_dev_helper()
959 SLIST_INSERT_HEAD(&entry->thdlist_head, thd, dev_list_entry); in open_dev_helper()
960 thd->entry = entry; in open_dev_helper()
967 while (thd->wait_for_open) { in open_dev_helper()
968 ret = thd_entry_event_wait(thd, &entry->thdlist_lock, pdata->fd_in); in open_dev_helper()
975 ret = (int) thd->err; in open_dev_helper()
977 remove_thd_entry(thd); in open_dev_helper()
979 SLIST_INSERT_HEAD(&pdata->thdlist_head, thd, parser_list_entry); in open_dev_helper()
1006 SLIST_INSERT_HEAD(&entry->thdlist_head, thd, dev_list_entry); in open_dev_helper()
1007 thd->entry = entry; in open_dev_helper()
1025 while (thd->wait_for_open) { in open_dev_helper()
1026 ret = thd_entry_event_wait(thd, &entry->thdlist_lock, pdata->fd_in); in open_dev_helper()
1033 ret = (int) thd->err; in open_dev_helper()
1035 remove_thd_entry(thd); in open_dev_helper()
1037 SLIST_INSERT_HEAD(&pdata->thdlist_head, thd, parser_list_entry); in open_dev_helper()
1045 close(thd->eventfd); in open_dev_helper()
1046 free(thd); in open_dev_helper()