CSE 124 Lecture Notes - Lecture 8: Errno.H, Hypertext Transfer Protocol
Document Summary
Struct timeval timeout; timeout. tv_sec = 10; timeout. tv_usec = 0; If (setsockopt( sockfd, sol_socket, so_rcvtimeo , (char *)&timeout, sizoof(timeout)) < 0) Changes the behavior of the socket s. t. It will return an error once the time from the timeout has timed out . If (numbytesrcvd < 0 && errno == ewouldblock ) { We need to handle when we timeout! printf( closing socket due to timeout\n ); close(cintsocket); return; Concurrency: progress of multiple elements of set overlap in time. Parallelism: progress of elements of the set occur at the same time. A single thread of execution can time slice a set of tasks to make partial progress over time. Time 0: first 25% of task 0. Time 1: first 25% of task 1. Time 4: 2nd 25% of task 0. Multiple execution units enable progress to be made simultaneously. Too much concurrency causes thrashing , excessive switching, lower performance. Time 0: 1st 25% of task 2.