Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
COMP1521 19T2 - Quiz 6 Solutions COMP1521 19T2 Computer Systems Fundamentals Quiz 6 Solutions Networking, Concurrency, IPC [Show with no answers]   [Show with all answers] Which of the following best describes how clients interact with servers in a socket-based client-server system? the client sends requests to the IP address of the server the client connects to the server, which returns a socket descriptor the client connects to the server, which sends a request key the client receives responses from the server on a VPN connection none of the other options is correct [show answer] Answer: B, the client connects to the server, which returns a socket descriptor Which of the following best describes what the bind(2) function does? fixes the physical location of a socket connects one socket descriptor to another, to start a session blocks the calling process until a network connection is available associates a network address with an open socket descriptor none of the other options is correct [show answer] Answer: D, associates a network address with an open socket descriptor What problem exists in the following code to implement a shared buffer with N slots? sem_t mutex; sem_init (&mutex, 1); sem_t nfree; sem_init (&nfree, N); Item buf[N];   void producer () { Item it = generateItem (); while (1) { sem_wait (&nfree); sem_wait (&mutex); addItemToBuffer (it, buf); sem_post (&mutex); } }   void consumer () { Item it; while (1) { sem_wait (&mutex); it = getItemFromBuffer (buf); sem_post (&mutex); sem_post (&nfree); consumeItem (it); } } Assume that functions like addItemToBuffer() and getItemFromBuffer() correctly implement a circular buffer of size N. the producer and consumer can be deadlocked the producer can add items into a full buffer the consumer can take items from an empty buffer mutually exclusive access to the buffer is not enforced none of the other options is correct [show answer] Answer: C, the consumer can take items from an empty buffer Which of the shell command pipelines below is equivalent to the following program? int main () { FILE *fp, *pp; char line[100]; fp = fopen ("file1", "r"); assert (fp != NULL); pp = popen ("wc -l", "w"); assert (pp != NULL); while (fgets (line, 100, fp) != NULL) fputs (line, pp); fclose (fp); pclose (pp); } Assume that all of the appropriate #includes have been done. wc -l `fopen file1` cat file1 | wc -l ls -l file1 wc -l | cat file1 none of the other options is correct [show answer] Answer: B, cat file1 | wc -l COMP1521 19T2: Computer Systems Fundamentals is brought to you by the School of Computer Science and Engineering at the University of New South Wales, Sydney. For all enquiries, please email the class account at cs1521@cse.unsw.edu.au CRICOS Provider 00098G