1 / 7

Lab4

Lab4. TA: Yi Cui 02/19/2013. Part 3. The category of CC caves: Cave 0-899: normal Cave 900-999: no exit Cave >999: monsters appear Two abnormal conditions with monsters (extra credit): A flybot is eaten Corrupted response . A flybot is eaten. Two conditions:

baird
Download Presentation

Lab4

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Lab4 TA: Yi Cui 02/19/2013

  2. Part 3 • The category of CC caves: • Cave 0-899: normal • Cave 900-999: no exit • Cave >999: monsters appear • Two abnormal conditions with monsters (extra credit): • A flybot is eaten • Corrupted response

  3. A flybot is eaten • Two conditions: • A timeout on WriteFile or ReadFile • An error in Windows API • The pipe is probably closed • Actions to take: • Put the node back to U • Update # running thread, # active thread • Kill the thread

  4. A flybot is eaten • How to detect? • Non-blocking ReadFile and WriteFile to detect timeout • Check the return value of Windows APIs to catch error • Non-blocking functions OVERLAPPED ol; memset(&ol, 0, sizeof(OVERLAPPED)); BOOL bRet = ReadFile(pipe, buffer, bytesToRead, NULL, &ol); if (bRet == 0 && GetLastError() != ERROR_IO_PENDING) // API error bRet = WaitForSingleObject (pipe, timeout); // normally 2 sec timeout GetOverlappedResult (pipe, &ol, ...);

  5. Corrupted response • Several conditions: • Invalid status code • Truncated message • Bogus room id • Actions to take: • Retry this node (do not kill the thread)

  6. Corrupted response • How to detect? • status != SUCCESS && status != FAILURE • Invalid status code • responseSize < sizeof(ResponseRobot) • nonsense response • (responseSize- sizeof(ResponseRobot)) % sizeof(NodTuple64) != 0 • Truncated response

  7. Q&A

More Related