Multi-thread ° pthread create Create thread according to detailed settings Pthread(series: join, detach, canceL.) Imply different polices other thread control methods
pthread_create Create thread according to detailed settings Pthread(series: join, detach, cancel…) Imply different polices. Other thread control methods?
lO Multiplexing Monitor sockets with select( int select(int maxed fd set *readfds, fd set *writefds, fd set *exceptfds, const struct timespec *timeout)i ● So what' san fd set? Bit vector with FD setsize bits maxed- Max file descriptor+1 readfs-Bit vector of read descriptors to monitor writefds -Bit vector of write descriptors to monitor exceptfds -Read the manpage, set to NULL timeout-How long to wait with no activity before returning, NULI for eternity
Monitor sockets with select() int select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timespec *timeout); So what’s an fd_set? Bit vector with FD_SETSIZE bits maxfd – Max file descriptor + 1 readfs – Bit vector of read descriptors to monitor writefds – Bit vector of write descriptors to monitor exceptfds – Read the manpage, set to NULL timeout – How long to wait with no activity before returning, NULL for eternity
So what about bit vectors? e void Fd ZERo (fd set *fdset)i Clears all the bits e void FD Set(int fd, fd set *fdset Sets the bit for fd void Fd Clr (int fdfd set faset Clears the bit for fd int FD ISSet (int fd, fd set *fdset)i Checks whether fds bit is set
void FD_ZERO(fd_set *fdset); Clears all the bits void FD_SET(int fd, fd_set *fdset); Sets the bit for fd void FD_CLR(int fd, fd_set *fdset); Clears the bit for fd int FD_ISSET(int fd, fd_set *fdset); Checks whether fd’s bit is set