exams Flashcards
Name an advantage of indirect message passing compared to direct message passing
+ allows the communication partners to be replaced
+ allows a message to be received by any process of a group of processes
For which combinations of asynchronous or synchronous send and receive is buffered
message passing fundamentally required
Buffers are necessary whenever sending is asynchronous. Asyn send-operations return immediately and potentially continues to overwrite the message, so the message has to be placed in a buffer. Synchronous send requires the sender to wait for the receiver, rendezvous-style message passing can be implemented and the message can be copied directly to the receiver.
Describe the producer-consumer problem. Name the cases in which one of the communication partners has to block.
The producer-consumer problem consists of senders (producer) and receivers (consumer) communicating via a shared bounded buffer. Producers put messages into the buffer and receivers remove messages from the buffer. A producer has to block while the buffer is full, and a sender has to block while the buffer is empty.
Name a synchronization primitive which is suitable to notify other threads and which
does not have this problem (the first thread might block forever)
Semaphore or condition variable.
While a condition variable is the best way to solve any such problem, counting semaphores can be used as well in some situations. Non-counting primitives such as mutexes or spinlocks are not suitable for notification problems in general as they can only be used once at a time, and subsequent attempts to wait for a condition either result in race conditions or excessive blocking.
Explain the difference between deadlock prevention and deadlock avoidance.
Deadlock prevention means that the system is restructured at design time so that arbitrary execution orders cant lead to deadlocks.
Deadlock avoidance, instead, restricts the allowed resource at runtime so that the system stays in a safe state, on the basis of knowledge about potential future resource requests by all involved processes.
Describe a method to detect deadlocks.
By creating the wait-for-graph of all resource acquisitions and by searching for cycles in that graph. If a resource allocation graph is used, the OS needs to check whether the cycle can be resolved by continuing processes outside of the cycle.
Assume a single processor system with non-interruptible interrupt service routines.
A resource that is protected by a spinlock is used in an interrupt service routine as
well as in interruptible kernel code.
In which situation does a deadlock occur? Identify the two resources involved in
cyclic waiting.
Deadlocks occur if the spinlock is held by the interruptible kernel code, that code is interrupted and the interrupt handler tries to acquire the spinlock. The interrupt handler prevents the previous code from proceeding but can’t proceed itself as the spinlock is locked. The second resource is the CPU (which is locked by the interrupt handler whereas the interruptible kernel code tries to acquire it)
external fragmentation and internal fragmentation
Internal fragmentation:
If a memory manager only offers memory blocks of fixed sizes, the difference between the requested size and block size cant be used.
External fragmentation:
The free space in physical memory may be too scattered to allow the allocation of a segment of a certain length, even though the total free space is available.
one way to reduce internal fragmentation when using paging and give two
disadvantages which are caused by this measure
by choosing a smaller page size
-increased page table size
-the TLB reach is reduced
-overhead
How can external fragmentation occur when using a buddy allocator
External fragmentation can happen for example if multiple blocks of a certain level
have been freed but cannot be merged (1 P) because their respective buddies still
contain valid allocations – you can only merge blocks that are buddies. In that case
the total free memory might suffice to fulfill a memory request, but the memory is not
contiguous
Explain, why the operating system cannot choose an arbitrary format for TLB entries
on a system with a software-managed TLB
The TLB entry format is specified in the instruction set architecture (ISA) of the respective CPU. Even with a software-managed TLB, the TLB is a hardware component, which is specified by the cpu manufacturer (1 P). The format of the page table
entries, however, can be chosen by the operating system.
Name and explain one advantage and one disadvantage of physical tagging compared to virtual tagging
Correct answers for advantages include ((1 P) for a valid advantage):
* No ambiguity (homonym problem): A virtual address might point to different
physical addresses at different points in time. When using physical tags, homonyms
can be detected which means that the cache does not have to be flushed at each
context switch.
* Synonyms (multiple virtual addresses point to the same physical address) can
be detected by checking all entries of the cache
* Easy write-back. If the cache entry needs to be written back to main memory,
no additional TLB lookup is required.
Disadvantage ((1 P) for a valid disadvantage):
Modern systems use virtual memory abstraction. A TLB look-up is required to translate the virtual address to the physical address which is used for tagging. The virtual
to physical translation takes some time and might increase the latency of the cache.
In order to reduce the latency of the L1 cache, a virtually indexed cache can be used.
Which coherence problem arises when using a virtually indexed, physically tagged
cache?
Aliasing (0.5 P) (coherence problem with synonyms). Virtual addresses that point to
the same physical address might be mapped to different cache sets.
Name some information that is stored in the “flags” field in
It stores the file access mode (read or write) as well as file creation flags passed to open().
The two processes pictured in the figure above share an entry in 2. How can this happen on a Unix system?
A call to fork() copies the local open file table, but not the entries in the global open file table. Consequently, two processes share an open file.