基本信息
文件名称:第15课编程函数.ppt
文件大小:3.38 MB
总页数:11 页
更新时间:2025-09-27
总字数:约小于1千字
文档摘要
第1页,共11页,星期日,2025年,2月5日创建进程:#includepthread.hpthread_create(pthread_t*thread, pthread_attr_t*attr, void*(*start_routine)(void*), void*arg)thread:线程标识符attr:线程属性设置start_routine:线程函数起始地址arg:传递给start_routine的参数第2页,共11页,星期日,2025年,2月5日第3页,共11页,星期日,2025年,2月5日进程退出:#includepthread.hpthread_exit(void*retval)retval:pthread_exit调用者线程的返回值,可由其他函数和pthread_join来检测获取。第4页,共11页,星期日,2025年,2月5日等待进程退出:#includepthread.hpthread_join(pthread_tth,void **thread_return)th:等待线程的标识符,不是pthread_t*th!!thread_return:用户定义指针,用来存储被等待线程的返回值线程实例见:thread.c第5页,共11页,星期日,2025年,2月5日第6页,共11页,星期日,2025年,2月5日第7页,共11页,星期日,2025年,2月5日Accept#includesys/socket.hintaccept(intsockfd,structsockaddr_in*cliaddr,socklen_t*addrlen);第8页,共11页,星期日,2025年,2月5日