Скачать презентацию
Идет загрузка презентации. Пожалуйста, подождите
Презентация была опубликована 10 лет назад пользователемГерасим Вышеславцев
1 Управление нитями Программирование с использованием POSIX thread library Иртегов Д.В. Учебное пособие подготовлено по заказу и при поддержке ООО «Сан Майкросистемс СПБ»
2 Функции управления pthread_self(3C) pthread_equal(3C) pthread_once(3C) sched_yield(3RT)
3 pthread_self(3C) #include pthread_t pthread_self(void); int pthread_equal(pthread_t t1, pthread_t t2);
4 pthread_once(3C) #include pthread_once_t once_control = PTHREAD_ONCE_INIT; int pthread_once( pthread_once_t *once_control, void (*init_routine)(void));
5 sched_yield(3RT) cc [ flags] file –lrt [ libraries ] #include int sched_yield(void); Нестандартная функция, эквивалент в Linux называется pthread_yield
6 Thread-specific data pthread_key_create(3C) pthread_key_delete(3C) pthread_setspecific(3C) pthread_getspecific(3C)
7 pthread_key_create #include int pthread_key_create( pthread_key_t *key, void (*destructor, void*)); Функция destructor вызывается при завершении нити.
8 pthread_get/setspecific #include int pthread_setspecific( pthread_key_t key, const void *value); int pthread_getspecific( pthread_key_t key);
9 Мониторинг исполнения программы -bash-3.00$ ps -efL UID PID PPID LWP NLWP C STIME TTY LTIME CMD daemon Sep 19 ? 0:00 /usr/lib/nfs/statd root Sep 19 ? 0:00 zsched root Sep 19 ? 0:00 /usr/lib/netsvc/yp/ypbind root Sep 19 ? 0:03 /sbin/init root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 1:14 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:14 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.startd root Sep 19 ? 0:00 /lib/svc/bin/svc.configd root Sep 19 ? 0:00 /lib/svc/bin/svc.configd root Sep 19 ? 0:00 /lib/svc/bin/svc.configd root Sep 19 ? 0:00 /lib/svc/bin/svc.configd root Sep 19 ? 0:01 /lib/svc/bin/svc.configd
10 Отладка - gdb Gdb: (gdb) info threads 3 process 35 thread 27 0x34e5 in sigpause () 2 process 35 thread 23 0x34e5 in sigpause () 1 process 35 thread 13 main (argc=1, argv=0x7ffffff8) at threadtest.c:68 Команды –info threads –thread threadno –thread apply [threadno] [all] args
11 Отладка - dbx (dbx) threads a ?() running in main() ?() asleep on 0xef in_swtch() b ?() running in sigwait() consumer() asleep on 0x22bb0 in _lwp_sema_wait() b consumer() breakpoint in Queue_dequeue() b producer() running in _thread_start()
12 Отладка – SunStudio 11
Еще похожие презентации в нашем архиве:
© 2024 MyShared Inc.
All rights reserved.