## a/lib格式

.a.lib是静态链接库格式，它们是ar压缩的.o.obj文件，并且内部有txt文件来记录每个目标文件中的符号信息。

## JNI调用签名对照表

Java中的基础类型和签名对照：

Java Native Signature
byte jbyte B
char jchar C
double jdouble D
float jfloat F
int jint I
short jshort S
long jlong J
boolean jboolean Z
void void V

1. L开头
2. ;结尾
3. 中间用/隔开包和类名

## 信号量的竞态条件

[CSAPP,2E,12.5.2]当有多个线程在等待同一个信号量的时候，不能够预测V操作要重启哪个线程。

## 内存对齐的作用

CPU在单位时间内能处理的一组二进制数称为，这组二进制数的位数称为字长。如果是32位CPU，其字长位32位也就是4字节。一般来说，字长越大，计算机处理信息的速度就越快。

CPU的处理速度比从内存中读取数据的速度快很多，所以减少CPU对内存空间的访问是提供程序性能的关键。因此采取内存对齐策略是提高程序性能的关键，因为是32为CPU，所以只需要按4字节对齐，上面的例子可以变为CPU只需要读取一次：

• 《Rust编程之道》4.1.3 P101.
• 《深入理解计算机系统第三版》3.9.3 P189

Guide to x86-64

## sendfile的优势

Unix system call interface:sendfile

transfer data between file descriptors

## 并发和并行(concurrency and parallel)

A logical flow whose execution overlaps in time with another flow is called a concurrent flow, and the two flows are said to run concurrently. More precisely, flows X and Y are concurrent with respect to each other if and only if X begins after Y begins and before Y finishes, or Y begins after X begins and before X finishes. For example, in Figure 8.12, processes A and B run concurrently, as do A and C. On the other hand, B and C do not run concurrently, because the last instruction of B executes before the first instruction of C.
The general phenomenon of multiple flows executing concurrently is known as concurrency. The notion of a process taking turns with other processes is also known as multitasking. Each time period that a process executes a portion of its flow is called a time slice. Thus, multitasking is also referred to as time slicing. For example, in Figure 8.12, the flow for Process A consists of two time slices.
Notice that the idea of concurrent flows is independent of the number of processor cores or computers that the flows are running on. If two flows overlap in time, then they are concurrent, even if they are running on the same processor. However, we will sometimes find it useful to identify a proper subset of concurrent flows known as parallel flows. If two flows are running concurrently on different processor cores or computers, then we say that they are parallel flows, that they are running in parallel, and have parallel execution.

## 为什么socket的IP地址是一个结构？

The <netinet/in.h> header shall define the in_addr structure, which shall include at least the following member:

in_addr_t Equivalent to the type uint32_t as described in <inttypes.h>.

[CSAPP,2e]把一个标量地址存放在结构中，是socket接口早起实现的不幸产物。为IP地址定义一个标量类型应该更有意义，但是现在更改已经太迟了，因为已经有大量应用基于此了。

## TCP/IP协议族

TCP/IP的协议族是一组不同的协议组合在一起构成的协议族(应用层协议(FTP/Telnet等)、运输层(TCP/UDP)、网络层(IP/ICMP/IGMP)、链路层(设备驱动程序及网络接口设备))。尽管通常称该协议族为TCP/IP，但TCP和IP只是其中的两种协议而已。

## POSIX data types

[IEEE Std 1003.1™ 2008]The implementation shall support one or more programming environments in which the widths of blksize_t, pid_t, size_t, ssize_t, and suseconds_t are no greater than the width of type long.