CS 3377 Final Exam Review

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

[APUE11] Which of the following items is shared by all thread in a process? Stack Program Counter File descriptors errno variable

File descriptors

[APUE15] According to the authors. When one end of a pipe is closed, two rules apply. Consider the following code segment. int fd[2]; pipe(fd); Which one of the following statements is CORRECT? For a pipe from the parent to the child, the parent closes both fd[0] and fd[1]. For a pipe from the parent to the child, the parent closes fd[1], and the child closes fd[0]. For a pipe from the child to the parent, the parent closes fd[1], and the child closes fd[0]. For a pipe from the child to the parent, the parent closes fd[0], and the child closes fd[1]. For a pipe from the parent to the child, the child closes fd[0] of the parent.

For a pipe from the child to the parent, the parent closes fd[1], and the child closes fd[0].

[TCPIP-UNP] Consider IPv4 and IPv6. Which one of the following choices is NOT correct? IPv4 has been the workhorse protocol of the IP suite since the early 1980s. IPv4 uses 16-bit addresses. IPv4 provides packet delivery service for TCP, UDP, SCTP, ICMP, and IGMP. IPv6 was designed in the mid-1990s as a replacement for IPv4. IPv6 has a larger address comprising 128 bits.

IPv4 uses 16-bit addresses. (correct is 32-bit)

[TCPIP-UNP] Consider TCP. Which one of the following choices is NOT correct? TCP is a connection-sensitive protocol TCP provides a reliable, full-duplex byte stream to its users. TCP sockets are an example of stream sockets. TCP takes care of details such as acknowledgments, timeouts, retransmissions, and the like. TCP provides a flow-control.

TCP is a connection-sensitive protocol

[APUE11.6] When a reader-writer lock is ____ locked, only one thread to ____ can have it while all threads attempting to read must wait until it is unlocked. allocate free access read update write

write

[APUE11.6] ____ is useful when used in a nonpreemptive kernel: besides providing a mutual exclusion mechanism, they block interrupts so an interrupt handler can't deadlock the system by trying to acquire a spin lock that is already locked (think of interrupts as another type of preemption). In these types of kernels, interrupt handlers can't sleep, so the only synchronization primitives they can use are ____. barrier conditional variable mutex message queue reader-writer lock semaphore spinlock

spinlock

[APUE11.6] Although implementations vary, reader-writer locks usually block additional readers if a lock is already held in read mode and a thread is blocked trying to acquire the lock in write mode. This prevents a constant stream of readers from ____ waiting writers. deadlocked exhausted interrupted lost sleeping starving spinning

starving

[APUE11] Spin locks are often used as low-level primitives to implement other types of locks, and can be implemented efficiently using ___ instruction. atomic swap-and-set test-and-set spin-and-set mutual-exclusive

test-and-set

[APUE11] If any thread within a process calls exit, _Exit, or _exit, then what is expected? the thread called exit will terminate. the thread and its children will terminate. the entire process (with all of its threads) terminates. no effect to the thread as exit is only for process.

the entire process (with all of its threads) terminates.

[Network] TTL in ping command is ______. time to live trace to link tracking time listen time to link traffic turnaround lifetime

time to live

[Network] You can find the routing information of the hosts from the current host to the target host with the ____ command. trace traceroute routelist ping arp

traceroute

[TCPIP-UNP] ______ is a computer network diagnostic tool for displaying the route (path) and measuring transit delays of packets across an Internet Protocol (IP) network. The history of the route is recorded as the round-trip times of the packets received from each successive host (remote node) in the route (path); the sum of the mean times in each hop is a measure of the total time spent to establish the connection. ping traceroute netstat ifconfig nslookup

traceroute

[Network] UDP and TCP are protocols at the following layers in the TCP/IP protocol suite. Network Application Transport Socket Ethernet Wireless

transport

[APUE15] According to the authors. Which one of the following statements is CORRECT?When a process is done with a shared resource that is controlled by a semaphore, the semaphore ______. value is decremented by 1 value is set to 0 value is incremented by 1 value is not affected goes in sleep

value is incremented by 1

[APUE15] According to the authors. Consider a filter. Which one of the following statements is NOT correct? A UNIX system filter is a program which reads from standard input and writes to standard output. Filters are normally connected linearly in shell pipelines. A filter becomes a coprocess when it generates the filter's input and reads the filter's output. A coprocess normally runs in the background from a shell The standard input and output of a coprocess are connected using a pipe.

A filter becomes a coprocess when it generates the filter's input and reads the filter's output.

[APUE15] According to the authors. Which one of the following statements is NOT correct?Consider Message Queue. A message queue is a linked list of messages stored within user process. A message queue is identified by a message queue identifier. A new queue is created or an existing queue opened by msgget. New messages are added to the end of a queue by msgsnd. Messages are fetched from a queue by msgrcv.

A message queue is a linked list of messages stored within user process.

[APUE11] When the default action initialed by a thread is to terminate the process of this thread, what is expected? A signal sent to a thread will terminate the entire process. A signal sent to the process will terminate all the threads of the process. A signal sent to a thread to be terminated but it is ignored by the process. This is an invalid action which a thread cannot initiate.

A signal sent to a thread will terminate the entire process.

[APUE11.6] With multiple threads of control, we can design our programs to do more than one thing at a time within a single process, with each thread handling a separate task. This approach can have several benefits. Which one of the following statements is NOT correct? Some problems can be partitioned so that overall program throughput can be improved. A single-threaded process with multiple tasks cannot serializes those tasks. The processing of independent tasks with multiple threads can be interleaved by assigning a separate thread per task. Interactive programs can improve response time with separate user-input-task thread and output-task thread from the other parts of the program. Multithreaded programming can be associated with multiprocessor or multicore systems. The benefits of a multithreaded programming model can be realized even if your program is running on a uniprocessor. A program can be simplified using threads regardless of the number of processors.

A single-threaded process with multiple tasks cannot serializes those tasks.

[APUE11.6] When multiple threads of control share the same memory, each thread should see a consistent view of its data. Which one of the following statements is NOT correct? If each thread uses variables that other threads don't read or modify, there is no consistency problem. A variable which is read-only could create a consistency problem with more than one thread reading its value at the same time. When one thread can modify a variable that other threads can read or modify, there is a need to synchronize the threads to ensure that they don't use an invalid value when accessing the variable's memory contents. When one thread modifies a variable, other threads can potentially see inconsistencies when reading the value of that variable. On processor architectures in which the modification takes more than one memory cycle, this can happen when the memory read is interleaved between the memory write cycles.

A variable which is read-only could create a consistency problem with more than one thread reading its value at the same time.

[Network] ARPA stands for ___ Advanced Research Programs Agency Aviation Related Programs Agency Advanced Research Projects Agency Aviation Related Projects Agency Advanced Research Process Act

Advanced Research Projects Agency

[APUE15] According to the authors. Which one of the following statements is NOT correct about PIPE? Pipes are the oldest form of UNIX System IPC. Pipes are provided by all UNIX systems. Pipes have been half duplex historically. All Linux systems now provide full-duplex pipes. Half-duplex pipes are still the most commonly used form of IPC.

All Linux systems now provide full-duplex pipes.

[APUE16] In a layered protocol architecture (e.g., TCP/IP), a benefit and rationale for a module at one layer relying on another module at the layer below for some service is: The lower-layer module can extend its service to multiple modules at the higher layer If called for, transparent to the higher-layer module, the lower-layer module can be replaced The higher-layer module can dispense with coding the logic for that service All of the above

All of the above

[Network] The ssh command _____. Invokes the Secure Shell client on your machine Allows you to execute a command on a remote machine Allows you to log on to a remote machine All of the above None of the above

All of the above

[Network] IPv4 addresses _____. Which one of the following is NOT correct? Are 4-byte long Are 32-bit long Have classes A, B, C, D, and E Are becoming obsolete. It will be replaced by IPv6

Are becoming obsolete.

[APUE11.6] With multiple threads of control, we can design our programs to do more than one thing at a time within a single process, with each thread handling a separate task. This approach can have several benefits.Which one of the following statements is NOT correct? To support asynchronous events by assigning a separate thread to handle each event type. Each thread can handle its event using a synchronous programming model. Asynchronous programming model is much simpler than Synchronous one. Multiple processes have to use complex mechanisms to share memory and file descriptors. Threads automatically have access to the same memory address space and file descriptors.

Asynchronous programming model is much simpler than Synchronous one.

[APUE16] Which of the following statements about socket programming with datagram is not correct? Datagram provides a connection-oriented service. each datagram is a self-contained message. Sending a datagram is analogous to mailing someone a letter as one can mail many letters, but no guarantee for the order of delivery. Sending a datagram is analogous to mailing someone a letter as some mails might get lost along the way and not be recovered. Sending a datagram is analogous to mailing someone a letter as each letter contains the address of the recipient, making the letter independent from all the others.

Datagram provides a connection-oriented service.

[APUE11.6] Assume that you have two mutexes, A and B, that you need to lock at the same time. If all threads always lock mutex A before mutex B, ____. Deadlocks can be avoided with these two mutexes. It is still possible to have a deadlock with these two mutexes. It is still possible to have a deadlock with the mutex A. It is still possible to have a deadlock with the mutex B. None of the above is correct.

Deadlocks can be avoided with these two mutexes.

[APUE15] According to the authors. Which one of the following statements is NOT correct? FIFO is a type of file. Creating a FIFO is similar to creating a file. FIFOs are sometimes called anonymous pipes. With FIFOs, unrelated processes can exchange data. The pathname for a FIFO exists in the file system.

FIFOs are sometimes called anonymous pipes.

[APUE15] According to the authors. When one end of a pipe is closed, two rules apply. Which one of the following statements is NOT correct? If we write to a pipe whose read end has been closed, the signal SIGPIPECL is generated. When we write to a pipe, the constant PIPE_BUF specifies the kernel's pipe buffer size. A write of PIPE_BUF bytes or less will not be interleaved with the writes from other processes to the same pipe. If multiple processes are writing to a pipe, and if we write more than PIPE_BUF bytes, the data might be interleaved with the data from the other writers. We can determine the value of PIPE_BUF by using pathconf or fpathconf.

If we write to a pipe whose read end has been closed, the signal SIGPIPECL is generated.

[APUE16] Which of the following is part of the syntax of a protocol (e.g., TCP/IP): Its packet format Its set of error codes Its functional purpose Its timing mechanisms

Its packet format

[Network] LAN stands for _____. Local Area Network Locally Administered Network Local-loop Area Network Local Action Network Landmark Ameria Network

Local Area Network

[APUE15] According to the authors. Consider the use of FIFO for shell commands in pipeline or for multiple-clients and the server. Which one of the following statements is NOT correct? FIFOs are used by shell commands to pass data from one shell pipeline to another. FIFOs are used as rendezvous points in client-server applications to pass data to each other. Multiple client-writers should keep the requests to be more than PIPE_BUF bytes in size. One solution for clients-server with one FIFO is to use client process ID with the request. With a unique FIFO for each client with its process ID, the server can create a unique FIFO.

Multiple client-writers should keep the requests to be more than PIPE_BUF bytes in size.

[Network] IP and ICMP are _____. Link layer protocols in the TCP/IP protocol suite Network layer protocols in the TCP/IP protocol suite Network layer protocols in ISO's 7-layer OSI model Names of two transport level protocols in the TCP/IP protocol suite Commands for Networking in Unix

Network layer protocols in the TCP/IP protocol suite

[APUE15] According to the authors. Which one of the following statements is NOT correct about PIPE? Normally the process that calls fork then calls pipe to have IPC between two processes. A pipe in a single process is next to useless for fstat function. POSIX.1 states that the st_size member of the stat structure is undefined for pipes. The fstat function could be applied to the file descriptor for the read end of the pipe. Many systems store in st_size the number of bytes available for reading in the pipe for fstat.

Normally the process that calls fork then calls pipe to have IPC between two processes.

[APUE15] According to the authors. When one end of a pipe is closed, two rules apply. Which one of the following statements is NOT correct? If we read from a pipe whose write end has been closed, read returns 0 to indicate an end of file after all the data has been read. One can write to a pipe whose write end has been closed. If we read from a pipe whose write end has been closed, this end of file is not generated until there are no more writers for the pipe. It's possible to duplicate a pipe descriptor so that multiple processes have the pipe open for writing. Normally there is a single reader and a single writer for a pipe.

One can write to a pipe whose write end has been closed.

[APUE15] According to the authors. Which one of the following statements is NOT correct about PIPE? Pipes can be used only between processes that have a common ancestor. A pipe is created by a process with fork, to be used between the parent and the child. UNIX domain sockets should be used to overcome the limitations of pipes. Pipes cannot be used for any full-duplex IPC communication. Pipes are used for a sequence of commands in a pipeline for the shell to execute.

Pipes cannot be used for any full-duplex IPC communication.

[APUE15] According to the authors. Consider Message Queue .On Linux, for example, the maximum number of messages is based on the maximum number of queues and the maximum amount of data allowed on the queues. The maximum number of queues, in turn, is based on the amount of ___ installed in the system. Note that the queue maximum byte size limit further limits the maximum size of a message to be placed on a queue.Select the best choice for the fill-in. Cache Memory Heap Memory Stack Memory RAM Memory Virtual Memory

RAM Memory

[Network] RFC is an acronym for ____. Remote Function Call Request for Comments Resource Function Control Research Forum Conference Report For Consensus

Request for Comments

[Network] The main function of the IP protocol is _____. Routing Congestion control Provide naming services Provide Names of two transport level protocols in the TCP/IP protocol suite Make Internet Efficient

Routing

[TCPIP-UNP] Consider TCP socket programming. The following diagram illustrates _____ process. Socket() bind() listen() accept() Client-side Server-side TCP bind TCP 3-way handshaking TCP 4-way handshaking Socket establishment and termination

Server-side

[APUE15] According to the authors. Which one of the following statements is NOT correct? Shared memory allows two or more processes to share a given region of memory. Shared memory is the slowest form of IPC Shared memory data does not need to be copied between the client and the server. Shared memory needs to be synchronized for an access among multiple processes. Often mutex, record locking, or semaphore is used to synchronize shared memory access.

Shared memory is the slowest form of IPC

[APUE15] According to the authors. Which one of the following statements is NOT correct? With a coprocess we have two one-way pipes to the other process A coprocess ouputs to the filter's standard input and read from the filter's standard output. The Korn shell provides coprocesses. The Bourne shell don't provide a way to connect processes together as coprocesses. The Bourne-again shell provides a way to connect processes together as coprocesses.

The Bourne-again shell provides a way to connect processes together as coprocesses.

[APUE16] Which of the following statements about socket programming (close and shutdown) is NOT correct? The close function deallocates the network endpoint only when all the active references are closed. If we duplicate the socket (with dup, for example), the socket won't be deallocated until we close the last file descriptor referring to it. the shutdown function allows an application to deactivate a socket independently of the number of active file descriptors referencing it. the shutdown function is possible to shut a socket down in one direction only. an application can shut a socket down for writing while still allowing to receive data sent by the process.

The close function deallocates the network endpoint only when all the active references are closed.

[APUE15] According to the authors. Which one of the following statements is NOT correct about PIPE? Consider the following code segment. int fd[2]; pipe(fd); fd[0] is open for reading. fd[1] is open for writing. With a duplex pipe if supported, fd[0] and fd[1] are open for both reading and writing. The fstat function returns a file type of PIPE for the file descriptor of either end of a pipe. One can test for a pipe with the S_ISFIFO macro.

The fstat function returns a file type of PIPE for the file descriptor of either end of a pipe.

[APUE15] According to the authors. Consider the pclose call. Which one of the following statements is NOT correct? The pclose function terminates the child process The pclose function closes the standard I/O stream The pclose function waits for the command to terminate The pclose function returns the termination status of the shell If the shell cannot be executed, the termination status of pclose is like shell exit(127).

The pclose function terminates the child process

[APUE11] When a thread is terminated, a thread can arrange for a function to be called when it exits. Which of the following statement is not correct? This function is known as thread cleanup handler. More than one function can be established and registered for a thread for its exit. This function is recorded in a stack This function will be executed (in reverse order, if more than one, of the registration). The process runs this function for the thread being terminated.

The process runs this function for the thread being terminated.

[APUE15] According to the authors. Consider the popen call as shown below. fp = popen(cmdstring, "w"); Which one of the following statements is NOT correct? popen call does a fork popen call does the exec call to execute the cmdstring The returned file pointer is readable if type is "w" The file pointer returned is connected to the standard input of cmdstring The child process does execute the comstring

The returned file pointer is readable if type is "w"

[APUE15] According to the authors. Which one of the following statements is NOT correct?Consider a semaphore to control only one resource. This is a binary semaphore The semaphore value is initialized to 0. The semaphore value is initialized to 1. When the resource is accessed, the semaphore value is decremented by 1 If the semaphore value is 0, the process requesting it goes into sleep.

The semaphore value is initialized to 0.

[APUE16] To write code for port-to-port communication (e.g., TCP/IP), a programmer uses: The datagram library Frame header structures The socket application programming interface Ethernet

The socket application programming interface

[APUE15] According to the authors. Consider the popen call as shown below. fp = popen(cmdstring, "r"); Which one of the following statements is NOT correct? popen call does a fork popen call does the exec call to execute the cmdstring popen call returns the file pointer which is readable if type is "r" The file pointer returned is connected to the standard input of cmdstring The child process does execute the comstring

The file pointer returned is connected to the standard input of cmdstring

[TCPIP-UNP] Consider client-server model. Which one of the following choices is NOT correct? There are three main classes of servers: synchronous, iterative, and concurrent. Iterative server iterates through each client, handling it one at a time. Concurrent server handles multiple clients at the same time. A concurrent server may spawn a child process with fork to serve a client. A concurrent server with a pool of threads may serve a client with a thread from the pool.

There are three main classes of servers: synchronous, iterative, and concurrent. (correct two main classes: iterative and concurrent)

[APUE15] According to the authors. Which one of the following statements is NOT correct? Semaphore is a counter used to provide access to a shared data object for multiple processes. If the value of the semaphore is positive, the process can use the resource. To use a resource with a semaphore, the process increments the semaphore value by 1. If the semaphore value is 0, the process to access the resource goes to sleep. If the semaphore value gets greater than 0, then the process waiting wakes up to access it.

To use a resource with a semaphore, the process increments the semaphore value by 1.

[Network] TCP stands for ______. Transmission and Computers Protocol Transmission Control Program Transmission Control Protocol Telecommunications Control Protocol Tremendous Call Protocol

Transmission Control Protocol

[Network] URL stands for ____. Unambiguous Resource Location Universal Resource Locale Uniform Resource Locator Unigram Response Locale Unified Response Log

Uniform Resource Locator

[Network] UDP stands for _____. User Data Protocol Useful Data Protocol Useful Datagram Protocol User Datagram Protocol Universal Data Protocol Unigram Destination Protocol

User Datagram Protocol

[APUE11] When multiple threads of control share the same memory (a shared variable), one needs to make sure that each thread sees a consistent view of its data. Which of the following statements is not correct? Select one best answer. If each thread uses variables while other threads don't read or modify, no consistency problems will exist. If a shared variable is read-only, there is no consistency problem. When a thread can modify a variable that other threads can read or modify, then inconsistency problem can occur. While a thread reads a variable, there is no consistency problem.

While a thread reads a variable, there is no consistency problem.

[APUE15] According to the authors. Which one of the following statements is NOT correct? Wring to a FIFO that no process has open for reading, the signal SIGPIPE is generated. When a FIFO is closed, an end of file is generated for the reader of the FIFO. It is common to have multiple writers for a given FIFO. With multiple readers for a given FIFO, one needs to have atomic read. PIPE_BUF specifies the maximum amount of data that can be written atomically to a FIFO.

With multiple readers for a given FIFO, one needs to have atomic read.

[APUE16] Which of the following statements about socket programming (accept function) is not correct? accept provides non-blocking socket. The file descriptor returned by accept is a socket descriptor that is connected to the client that called connect. The new socket descriptor by accept has the same socket type and address family as the original socket (sockfd). The original socket passed to accept is not associated with the connection, but instead remains available to receive additional connect requests. On return, accept will fill in the client's address in the buffer and update the integer field (len) to reflect the size of the address. If no connect requests are pending, accept will block until one arrives.

accept provides non-blocking socket.

[TCPIP-UNP] Consider the features or advantages of TCP. TCP provides ______ connection over which TCP client establishes with servers and exchanges data. Which one of the following choices is NOT correct? atomic full-duplexed reliable stateful synchronous

atomic

[APUE11.6] The pthread_join function acts as a ____ to allow one thread to wait until another thread exits. barrier conditional variable mutex message queue reader-writer lock semaphore spinlock

barrier

[APUE11] ___ is a synchronization mechanism that can be used to coordinate multiple threads working in parallel. This allows each thread to wait until all cooperating threads have reached the same point, and then continue executing from there. lock mutex conditional variable spin lock barrier semaphore

barrier

[APUE11] pthread_join function acts as ___ to allow one thread to wait until another thread exits. lock mutex conditional variable spin lock barrier semaphore

barrier

[Network] You can display the domain names and IP addresses of the hosts on your computer network with the _____ command. more /etc/service cat /etc/hosts echo /etc/dns grep "host" find /etc -name "network"

cat /etc/hosts

[APUE11.6] The condition is the state of the work queue. We protect the condition with a mutex and evaluate the condition in a while loop. When we put a message on the work queue, we need to hold the mutex, but we don't need to hold the mutex when we signal the waiting threads. As long as it is okay for a thread to pull the message off the queue before we call a signal, we can do this after releasing the mutex. Since we check the condition in a while loop, this doesn't present a problem; a thread will wake up, find that the queue is still empty, and go back to waiting again. If the code couldn't tolerate this race, we would need to hold the mutex when we signal the threads. This is about ____ mechanism. barrier conditional variable mutex message queue reader-writer lock semaphore socket signal

conditional variable

[APUE11.6] ____ is another synchronization mechanism available to threads. These synchronization objects provide a place for threads to rendezvous. When used with mutexes, it allows threads to wait in a race-free way for arbitrary conditions to occur. barrier conditional variable mutex message queue reader-writer lock semaphore socket spin lock

conditional variable

[APUE11.6] When we use more than one mutex in our programs, a(n) ____ can occur if we allow one thread to hold a mutex and block while trying to lock a second mutex at the same time that another thread holding the second mutex tries to lock the first mutex. Neither thread can proceed, because each needs a resource that is held by the other, so we have a(n) ____. mutex locking deadlock mutex interruption spin busy-wait threshing

deadlock

[APUE11.6] A thread will ____ if it tries to lock the same mutex twice. allocate mutex deadlock itself free mutex first interrupt itself spin itself unlock mutex

deadlock itself

[Network] The following command can be used to display information about the user "richard" on the utdallas.edu host. finger [email protected] rwho [email protected] info [email protected] display [email protected] netinfo [email protected]

finger [email protected]

[APUE15] According to the authors. Consider the popen and pclose functions which will do ____. Which one of the following statements is NOT correct? create a pipe fork a parent process and a child process in a pipeline close the unused ends of the pipe execute a shell to run the command wait for the command to terminate

fork a parent process and a child process in a pipeline

[TCPIP-UNP] Client needs to know Server's IP address and port to be connected. Server's IP address (sin_addr) and port number (sin_port) fields in the Internet socket address structure (sockaddr_in) must be in specific formats. This ____ function converts a binary port number to the proper format (sin_port). host2net htons inet_h2n inet_host2net inetport

htons

[Network] You can determine the IP address of your computer on a UNIX machine by using the ______ command. whoami myhost uname ifconfig http TCP

ifconfig

[TCPIP-UNP] _____ is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, it displays the status of the currently active interfaces. ping traceroute netstat ifconfig nslookup

ifconfig

[TCPIP-UNP] Client needs to know Server's IP address and port to be connected. Server's IP address (sin_addr) and port number (sin_port) fields in the Internet socket address structure (sockaddr_in) must be in specific formats. This ____ function convert an IP address in ASCII command-line argument (for example, "192.10.16.4") into the proper format (sin_addr). inet_addr32 or str2port inet_port inet_sin or sin_port16 inet_aton or inet_addr sin_addr

inet_aton or inet_addr

[Network] IPv4 address 127.0.0.1 is for _____. mac localhost default router default gateway default TCP address

localhost

[APUE11.6] While it is set, any other thread that tries to set it will block until we release it. If more than one thread is blocked when we unlock the ____, then all threads blocked on the lock will be made runnable, and the first one to run will be able to set the lock. The others will see that the ____ is still locked and go back to waiting for it to become available again. In this way, only one thread will proceed at a time. barrier conditional variable deadlock livelock message queue mutex pipe semaphore

mutex

[APUE11] A ___ is basically a lock that a thread does set (lock) before accessing a shared resource and release(unlock) when we're done. bit-lock mutex conditional variable semaphore message queue

mutex

[APUE11.6] The _____ mechanism works only if we design our threads to follow the same data-access rules. The operating system doesn't serialize access to data for us. If we allow one thread to access a shared resource without first acquiring a lock, then inconsistencies can occur even though the rest of our threads do acquire the lock before attempting to access the shared resource. asynchronization blocking mutual-exclusion nonblocking preemption resource-sharing synchronization

mutual-exclusion

[TCPIP-UNP] ____ is a network utility tool that displays the local host's network connections for transmission control protocol ((both incoming and outgoing), routing tables, and a number of network interface and network protocol statistics. It is used for finding problems in the network and to determine the amount of traffic on the network as a performance measurement. This command is used to find which TCP port is bound or free so that one may choose a free port for one's server to bind and listen. ping traceroute netstat ifconfig nslookup

netstat

[APUE11] Spin locks are useful when used in a(n) ___ kernel: besides providing a mutual exclusion mechanism, they block interrupts so an interrupt handler can't deadlock the system by trying to acquire a spin lock that is already locked. preemptive nonpreemptive reentrant nonretentrant concurrent time-sharing

nonpreemptive

[Network] This command ___ will tell you whether a host in Internet is up and responding, or not. netstat host ifconfig ping uname who

ping

[APUE11] Spin locks are useful when running in real-time scheduling class that doesn't allow ____. preemption single thread of control reentrant processes concurrency mutex time-sharing

preemption

[APUE11] A thread can arrange for functions to be called when it exits, similar to the way that the atexit function. pthread_create pthread_exit pthread_join pthread_cleanup_push pthread_self pthread_cancel

pthread_cleanup_push

[APUE11] What is a thread primitive, corresponding to fork for process. pthread_create pthread_exit pthread_join pthread_cleanup_push pthread_self pthread_cancel

pthread_create

[APUE11] Which of the following functions is used to create a thread? pthread_detach pthread_exit pthread_join pthread_self pthread_create

pthread_create

[APUE11] If a thread knows that no thread cares about its return value, then which of the following functions does it call to indicate that resources associated with it can be released on termination? pthread_detach pthread_exit pthread_join pthread_self pthread_create

pthread_detach

[APUE11] What is a thread primitive, corresponding to waitpid for process. pthread_create pthread_exit pthread_join pthread_cleanup_push pthread_self pthread_cancel

pthread_join

[APUE11.6] If we allocate the mutex dynamically (by calling malloc, for example), then we need to call _____ before freeing the memory. pthread_mutex_destroy pthread_mutex_deallocate pthread_mutex_free pthread_mutex_exit pthread_mutex_return

pthread_mutex_destroy

[APUE11] Consider the following statements for a lock in thread programming. pthread_mutex_t MutexLock; pthread_mutex_init(&MutexLock, NULL); Which of the following statement will lock the mutex called MutexLock?

pthread_mutex_lock(&MutexLock);

[APUE11.6] One additional mutex primitive allows us to bound the time that a thread blocks when a mutex it is trying to acquire is already locked. The ____ function is equivalent to pthread_mutex_lock, but if the timeout value is reached, it will return the error code ETIMEDOUT without locking the mutex. pthread_mutex_time pthread_mutex_timelock pthread_mutex_timedlock pthread_mutex_timeset pthread_mutex_timelimit

pthread_mutex_timedlock

[APUE11.6] A reader-writer lock is initialized by calling ____. pthread_reader_writer_lock_init pthread_rw_lock_init pthread_rwlock_init pthread_readwritelock_init pthread_rdwtlock_init

pthread_rwlock_init

[APUE11.6] To lock a reader-writer lock in read mode, we call ____. pthread_rwlock_read pthread_readlock pthread_writelock pthread_rwlock_rdlock pthread_rwlock_readlock

pthread_rwlock_rdlock

[APUE11] Which of the following functions is used by a thread to obtain its ID? pthread_detach pthread_exit pthread_join pthread_self pthread_create

pthread_self

[APUE11] Consider the following function to be run by a thread. void *PrintHello(void *threadid) { . . . } pthread_t tid; int rc; Which of the following statement is correct to create a thread that executes a function called PrintHello? rc = pthread_init(&tid, NULL, PrintHello, (void *)1); rc = pthread_create(tid, NULL, *PrintHello, 1); rc = pthread_create(&tid, NULL, &PrintHello, (void *)1); rc = pthread_create(&tid, NULL, PrintHello, (void *)1); rc = pthread_new(&tid, NULL, PrintHello, 1);

rc = pthread_create(&tid, NULL, PrintHello, (void *)1);

[APUE11.6] When a reader-writer lock is ____ locked, all threads attempting to ___ are given access, but all threads attempting to write must wait until the lock is released by all threads in ____. allocate free access read update write

read

[APUE11.6] Only one thread at a time can hold a(n) ____ in write mode, but multiple threads can hold a(n) ____ in read mode at the same time. barrier conditional variable mutex message queue reader-writer lock semaphore socket signal

reader-writer lock

[APUE11.6] _____ is well suited for situations in which data structures are read more often than they are modified. When a(n) ____ is held in write mode, the data structure it protects can be modified safely, since only one thread at a time can hold the lock in write mode. barrier conditional variable mutex message queue reader-writer lock semaphore socket spin lock

reader-writer lock

[APUE15] According to the authors. Which one of the following statements is NOT correct?Consider the performance of mutex, record lock and semaphore in Linux. mutexes in shared memory outperform both semaphores and record locking. record locking is slower than semaphores record locking is preferred if it is for single resource and does not need any fancy features. With record locking, the system takes care of any lingering locks when a process terminates. Recovery from process termination is difficult with mutex among multiple processes.

record locking is slower than semaphores

[APUE16] ___ allows processes running on different computers (connected to a common network) to communicate with one another. process thread socket semaphore

socket

[APUE11] ___ is like a mutex, except that instead of blocking a process by sleeping, the process is blocked by busy-waiting until the lock can be acquired. simple-lock busy-mutex wait-lock conditional variable spin-lock

spin-lock

[APUE11.6] At user level, ____ is not as useful unless you are running in a real-time scheduling class that doesn't allow preemption. User-level threads running in a time-sharing scheduling class can be descheduled when their time quantum expires or when a thread with a higher scheduling priority becomes runnable. In these cases, if a thread is holding ____, it will be put to sleep and other threads blocked on the lock will continue waiting longer than intended. barrier conditional variable mutex message queue reader-writer lock semaphore spinlock

spinlock


Ensembles d'études connexes

Systems of Linear Equations and Inequalities - Part 1

View Set

American Republic Chapter 1 Activity 5

View Set

U.S. Citizenship and Immigration Services (AMERICAN HISTORY)

View Set