Operating System: Three Easy Pieces --- Load-Linked and Store-Conditional (Note)

Some platforms provide a pair of instructions that work in concert to help build critical sections.

On the MIPS architecture, for example, the load-linked and store-conditional instructions can be

used in tandem to build locks and other concurrent structures. The C pseudocode for these

instructions is as found in figure 28.5. Alpha, PowerPC, and ARM provide similar instructions.

The load-linked operates much like a typical load instruction, and simply fetches a value from

memory and places it in a register. The key difference comes with the store-conditional, which

only succeeds and updates the value stored at the address just load-linked from if no intervening

store to the address has taken place. In the case of success, the store-conditional returns 1 and

updates the value at ptr to value; if it fails, the value at ptr is not updated and 0 is returned.

时间: 2024-10-10 13:25:54

Operating System: Three Easy Pieces --- Load-Linked and Store-Conditional (Note)的相关文章

Operating System: Three Easy Pieces --- Mechanism: Limited Direct Execution (Note)

In order to virtualize the CPU, the operating system needs to somehow share the physical CPU among many jobs  running seemingly at the same time. The basic idea is simple: run one process for a little while, then run another, and so forth. By time sh

Operating System: Three Easy Pieces --- Process (Note)

1. How can the operating system provide the illusion of a nearly-endless supply of said CPUs? The OS creates this illusion by virtualizing the CPU. The basic technique, known as the time- sharing the CPU, allows users to run as many concurrent proces

Operating System: Three Easy Pieces --- Locks: Pthread Locks (Note)

The name that the POSIX library uses for a lock is mutex, as it is used to provide mutual exclusion between threads, i.e., if one thread is in the critical sections, it excludes the others from entering until it has completed the section. Thus, when

Operating System: Three Easy Pieces --- Limited Directed Execution (Note)

In order to virtualize the CPU, the operating system needs to somehow share the physical CPU among many jobs running seemingly at the same time. The basic idea is simple: run one process for a little while, then run another one, and so forth. By time

Operating System: Three Easy Pieces --- Locks: Test and Set (Note)

Because disabling interrupts does not work on multiple processors, system designers started to invent hardware support for locking. The earliest multiprocessor systems, such as the Burroughts B5000 in the  early 1960's, had such support; today all sy

Operating System: Three Easy Pieces --- Paging: TLB (Note)

Using paging as the core mechanism to support virtual memeory can lead to high performance overheads. By chopping the address space into small, fixed-sized units (pages), paging requires a large amount of mapping information. Because that mapping inf

Operating System: Three Easy Pieces --- Beyond Physical Memory: Mechanisms (Note)

Thus far, we have assumed that an address space is unrealistically small and fits into the physical memory. In fact, we have been assuming that every address space of ervery running process fits into memory. We will now relax these big assumptions, a

Operating System: Three Easy Pieces --- Thread API (Note)

This chapter briefly covers the main properties of the thread API. Each part will be explained further in the subsequent chapters, as we know how to use the API. More details can be found in various books and online sources. We should note that the s

Operating System: Three Easy Pieces --- Page Fault (Note)

Recall that with TLB misses, we have two types of systems: Hardware managed TLBs (where the hardware looks in the page table to find the desired translation) and software managed TLBs ( where the OS does). In either type of systems, if a page is not