【正文】
perror( “write” )。The ?zerocopy? initiative A look at the ?zerocopy? concept and an x86 Linux implementation for the case of outgoing packets From Wikipedia, the free encyclopedia: Zerocopy is an adjective that refers to puter operations in which the CPU does not perform the task of copying data from one area of memory to another. The availability of zerocopy versions of operating system elements such as device drivers, file systems and work protocol stacks greatly increases the performance of many applications, since using a CPU that is capable of plex operations just to make copies of data can be a great waste of resources. Zerocopy also reduces the number of contextswitches from User space to Kernel space and viceversa. Several OS like Linux support zero copying of files through specific API39。 exit(1)。 // pgtblindex (10bits) offset = ((int)buf 0) amp。 pfn_frame = (pgtbl[ pindex ] 12)。mem_map[ pfn_pgtbl ]。 // frameoffset (12bits) // then walk the CPU?s pagingtables to get buf?s physicaladdress asm(“ mov %%cr3, %%eax \n mov %%eax, %0 “ : “=m”(_cr3) : : “ax” )。 } Transmit operation application program user databuffer runtime library write() Linux OS kernel nic devicedriver my_write() file subsystem hardware packet buffer copy_from_user() DMA user space kernel space We want to eliminate this copyingoperation Our driver?s packetlayout packetbuffer in kernelspace destnaddress sourceaddress TYPE/ LENGTH count data data data – baseaddress (64bits) status Packet length special CSS 16 bytes cmd CSO Format for Legacy Transmit