- 博客(22)
- 收藏
- 关注
原创 Error Handling
Programmers should always check the error codes returned by system-level functions. There are many subtle ways that things can go wrong, and it only makes sense to use the status information that th
2013-12-30 22:31:03 674
原创 Using Threads for Parallelism
Thus far in our study of concurrency, we have assumed concurrent threads executing on uniprocessor systems. However, many modern machines have multi-core processors. Concurrent programs often run fa
2013-12-30 14:33:47 600
原创 Concurrent Programming with I/O Multiplexing
Suppose you are asked to write an echo server that can also respond to interactive commands that the user types to standard input. In this case, the server must respond to two independent I/O events
2013-12-25 16:21:56 837
原创 Concurrent Programming with Processes
Applications that use application-level concurrency are known asconcurrent programs. Modern operating systems provide three basic approaches for building concurrent programs: processes, I/O multiple
2013-12-25 15:19:15 741
原创 Client and Server Code on Network Programming
The best way to learn the sockets interface is to study example code. The code for an echo client is showed below.#include #include #include int main(int argc, char **argv){ char *hostname, b
2013-12-25 10:15:37 703
原创 Sharing Files
Suppose the disk filefoobar.txt consists of the six ASCII characters "foobar". Then what is the output of the following program?int main(){ char c; int fd1 = open("foobar.txt", O_RDONLY,
2013-12-21 19:41:55 779
原创 Common Memory-Related Bugs in C Programs
Managing and using virtual memory can be a difficult and error-prone task for the C programmers. Memory-related bugs are among the most frightening because they often manifest themselves at a distan
2013-12-18 18:45:23 733
原创 Garbage Collection
A garbage collector is a dynamic storage allocator that automatically frees allocated blocks that are no longer needed by the program. We introduce Mark&Sweep garbage collectors here. A Mark&
2013-12-18 16:00:06 876
原创 Building Your Own Allocator
While it is certainly possible to use the low-levelmmap and munmap functions to create and delete areas of virtual memory, C programmers typically find it more convenient and more portable to use a
2013-12-18 15:30:32 650
原创 Using mmap to Copy an Arbitrary-sized Disk File to stdout
The low-level system callsmmap and munmap can be used to create and delete areas of virtual memory. We will write a C programmmapcopy.c that uses mmap to copy an arbitrary-sized disk file tostdo
2013-12-17 09:37:38 1047
原创 Nonlocal Jumps
C provides a form of user-level exceptional control flow, called anonlocal jump, that transfers control directly from one function to another currently executing function without having to go throug
2013-12-12 22:34:11 620
原创 Signal Handling on Exceptional Control Flow
A signal is a small message that notifies a process that an event of some type has occurred in the system. Consider the following program.#include #include "csapp.h"using namespace std;pid_t pid
2013-12-12 21:46:28 603
原创 Using waitpid to Reap Zombie Children
When a process terminates for any reason, the kernel does not remove it from the system immediately. Instead, the process is kept around in a terminated state until it is reaped by its parent. When
2013-12-11 11:32:34 1068
原创 An Application Program Dynamically Loading and Linking the Shared Library
Shared libraries are a modern innovation that address the disadvantages of static libraries. A shared library is an object module that, at run time, can be loaded at an arbitrary memory address and li
2013-12-08 09:14:54 711
原创 How Linkers Relocate Symbol References
Once the linker has completed the symbol resolution step, it has associated each symbol reference in the code with exactly one symbol definition. At this point, the linker knows the exact sizes of t
2013-12-07 08:42:11 818
原创 How Linkers Use Static Libraries to Resolve References
While static libraries are useful and essential tools, they are also a source of confusion to programmers because of the way the Unix linker uses them to resolve external references. During the symb
2013-12-06 14:15:50 577
原创 Using Blocking to Increase Temporal Locality
In the last essay Rearranging Loops to Increase Spatial Locality we saw how some simple rearrangements of the loops could increase spatial locality. But observe that even with good loop nestings,
2013-12-04 10:27:53 1099
原创 Rearranging Loops to Increase Spatial Locality
Consider the problem of multiplying a pair ofn×n matrices: C = AB. For example, if n=2, then Matrix multiply is usually implemented using three nested loops, which are identified by their
2013-12-04 09:38:59 562
原创 Writing Cache-friendly Code
In the previous essayExhibiting Good Locality in Your Programs, we presented two functions namedsumarrayrows andsumarraycols respectively. And we knew thatsumarrayrows had a stride-1 reference
2013-12-02 10:49:40 1025
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人