锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲深爱激情,国产精一区二区三区,欧美电影资源http://m.shnenglu.com/beautykingdom/category/12530.htmlzh-cnTue, 13 Sep 2011 16:44:03 GMTTue, 13 Sep 2011 16:44:03 GMT60ubuntu涓嬬紪璇戝唴鏍?/title><link>http://m.shnenglu.com/beautykingdom/archive/2011/09/14/155714.html</link><dc:creator>chatler</dc:creator><author>chatler</author><pubDate>Tue, 13 Sep 2011 16:02:00 GMT</pubDate><guid>http://m.shnenglu.com/beautykingdom/archive/2011/09/14/155714.html</guid><wfw:comment>http://m.shnenglu.com/beautykingdom/comments/155714.html</wfw:comment><comments>http://m.shnenglu.com/beautykingdom/archive/2011/09/14/155714.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/beautykingdom/comments/commentRss/155714.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/beautykingdom/services/trackbacks/155714.html</trackback:ping><description><![CDATA[<div>鍏坢ake menuconfig錛岄夊畾cpu鍨嬪彿錛岃涓嶄細鍦╥nstall鍐呮牳騫墮噸鍚殑鏃跺欏嚭鐜癱pu unsupported涔嬬被鐨勯敊銆傚叿浣撶殑鍛戒護涓猴細<br /><span style="widows: 2; text-transform: none; background-color: rgb(250,250,250); text-indent: 0px; letter-spacing: normal; font: 12px/16px Monaco, 'Courier New', monospace; white-space: normal; orphans: 2; color: rgb(0,102,0); word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span">sudo make-kpkg --initrd --append-to-version=dell1400 kernel_image kernel-headers<br /><span style="widows: 2; text-transform: none; background-color: rgb(250,250,250); text-indent: 0px; letter-spacing: normal; font: 12px/16px Monaco, 'Courier New', monospace; white-space: normal; orphans: 2; color: rgb(0,102,0); word-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class="Apple-style-span">sudo dpkg -i   linux-image-*.deb<br /><br /><br />references:<br />1.<a >http://forum.ubuntu.org.cn/viewtopic.php?t=134404</a></span></span></div><img src ="http://m.shnenglu.com/beautykingdom/aggbug/155714.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/beautykingdom/" target="_blank">chatler</a> 2011-09-14 00:02 <a href="http://m.shnenglu.com/beautykingdom/archive/2011/09/14/155714.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title><杞?gt;how to start a kernel threadhttp://m.shnenglu.com/beautykingdom/archive/2011/03/22/142512.htmlchatlerchatlerTue, 22 Mar 2011 13:08:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2011/03/22/142512.htmlhttp://m.shnenglu.com/beautykingdom/comments/142512.htmlhttp://m.shnenglu.com/beautykingdom/archive/2011/03/22/142512.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/142512.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/142512.htmlLinux Kernel Threads in Device Drivers 
Purpose 
This examples shows how to create and stop a kernel thread. 
The driver is implemented as a loadable module. In the init_module() routine five kernel threads are created. This kernel threads sleep one second, wake up, print a message and fall asleep again. On unload of the module (cleanup_module), the kernel threads are killed. 
The example has been tested with Linux kernel 2.4.2 on Intel (uni processor only) and Alpha platform (COMPAQ Personal Workstation 500au (uni processor), DS20 and ES40 (SMP). 
A version for the 2.2 kernel can be found here. Note: depending on the context of the creator of the threads the new threads may inherit properties from the parent you do not want to have. The new version avoids this by having keventd create the threads. The 2.2. kernel do not have a keventd, so this approach is not implementable there. 

Functions in example 
start_kthread: creates a new kernel thread. Can be called from any process context but not from interrupt. The functions blocks until the thread started. 
stop_kthread: stop the thread. Can be called from any process context but the thread to be terminated. Cannot be called from interrupt context. The function blocks until the thread terminated. 
init_kthread: sets the environment of the new threads. Is to be called out of the created thread. 
exit_kthread: needs to be called by the thread to be terminated on exit 
Creation of new Thread 
A new thread is created with kernel_thread(). The thread inherits properties from its parents. To make sure that we do not get any weired properties, we let keventd create the new thread. 
The new thread is created with start_kthread(). It uses a semaphore to block until the new thread is running. A down() blocks the start_kthread() routine until the corresponding up() call in init_kthread() is executed. 
The new thread must call init_kthread() in order to let the creator continue. 
Stop of new Thread 
stop_kthread() sets a flag that the thread uses to determine whether do die or not and sends a SIGKILL to the thread. This signal causes the thread to be woken up. On wakeup it will check for the flag and then terminate itself by calling exit_kthread and returning from the thread function. With a semaphore the stop_kthread() function blocks until the thread terminated. 
Initialization of new Thread 
Within the new created thread, init_kthread() needs to be called. This function sets a signal mask, initialises a wait queue, the termination flag and sets a new name for the thread. With a up() call it notifies the creator that the setup is done. 
Exit of new Thread 
When the thread receives the notification to terminate itself, is calls the exit_kthread() function. It notifies the stop_kthread() function that it terminated with an up() call. 
The new Thread itself 
The new thread is implemented in the example_thread() function. It runs an endless loop (for(;;)). In the loop it falls asleep with the interruptible_sleep_on_timeout() function. It comes out of this function either when the timeout expires or when a signal got caught. 
The "work" in the thread is to print out a message with printk. 
Kernel Versions 
The example has been tested on 2.4.2. 
Example Device Driver Code 
The example consists of four files: kthread.h, kthread.c, thread_drv.c and a Makefile 
kthread.h 
#ifndef _KTHREAD_H 
#define _KTHREAD_H 
#include <linux/config.h> 
#include <linux/version.h> 

#include <linux/kernel.h> 
#include <linux/sched.h> 
#include <linux/tqueue.h> 
#include <linux/wait.h> 

#include <asm/unistd.h> 
#include <asm/semaphore.h> 

/* a structure to store all information we need 
for our thread */ 
typedef struct kthread_struct 
{ 
/* private data */ 

/* Linux task structure of thread */ 
struct task_struct *thread; 
/* Task queue need to launch thread */ 
struct tq_struct tq; 
/* function to be started as thread */ 
void (*function) (struct kthread_struct *kthread); 
/* semaphore needed on start and creation of thread. */ 
struct semaphore startstop_sem; 

/* public data */ 

/* queue thread is waiting on. Gets initialized by 
init_kthread, can be used by thread itself. 
*/ 
wait_queue_head_t queue; 
/* flag to tell thread whether to die or not. 
When the thread receives a signal, it must check 
the value of terminate and call exit_kthread and terminate 
if set. 
*/ 
int terminate; 
/* additional data to pass to kernel thread */ 
void *arg; 
} kthread_t; 

/* prototypes */ 

/* start new kthread (called by creator) */ 
void start_kthread(void (*func)(kthread_t *), kthread_t *kthread); 

/* stop a running thread (called by "killer") */ 
void stop_kthread(kthread_t *kthread); 

/* setup thread environment (called by new thread) */ 
void init_kthread(kthread_t *kthread, char *name); 

/* cleanup thread environment (called by thread upon receiving termination signal) */ 
void exit_kthread(kthread_t *kthread); 

#endif 

kthread.c 
#include <linux/config.h> 
#include <linux/version.h> 

#if defined(MODVERSIONS) 
#include <linux/modversions.h> 
#endif 
#include <linux/kernel.h> 
#include <linux/sched.h> 
#include <linux/tqueue.h> 
#include <linux/wait.h> 
#include <linux/signal.h> 

#include <asm/semaphore.h> 
#include <asm/smplock.h> 

#include "kthread.h" 

/* private functions */ 
static void kthread_launcher(void *data) 
{ 
kthread_t *kthread = data; 
kernel_thread((int (*)(void *))kthread->function, (void *)kthread, 0); 

} 

/* public functions */ 

/* create a new kernel thread. Called by the creator. */ 
void start_kthread(void (*func)(kthread_t *), kthread_t *kthread) 
{ 
/* initialize the semaphore: 
we start with the semaphore locked. The new kernel 
thread will setup its stuff and unlock it. This 
control flow (the one that creates the thread) blocks 
in the down operation below until the thread has reached 
the up() operation. 
*/ 
init_MUTEX_LOCKED(&kthread->startstop_sem); 

/* store the function to be executed in the data passed to 
the launcher */ 
kthread->function=func; 

/* create the new thread my running a task through keventd */ 

/* initialize the task queue structure */ 
kthread->tq.sync = 0; 
INIT_LIST_HEAD(&kthread->tq.list); 
kthread->tq.routine = kthread_launcher; 
kthread->tq.data = kthread; 

/* and schedule it for execution */ 
schedule_task(&kthread->tq); 

/* wait till it has reached the setup_thread routine */ 
down(&kthread->startstop_sem); 

} 

/* stop a kernel thread. Called by the removing instance */ 
void stop_kthread(kthread_t *kthread) 
{ 
if (kthread->thread == NULL) 
{ 
printk("stop_kthread: killing non existing thread!\n"); 
return; 
} 

/* this function needs to be protected with the big 
kernel lock (lock_kernel()). The lock must be 
grabbed before changing the terminate 
flag and released after the down() call. */ 
lock_kernel(); 

/* initialize the semaphore. We lock it here, the 
leave_thread call of the thread to be terminated 
will unlock it. As soon as we see the semaphore 
unlocked, we know that the thread has exited. 
*/ 
init_MUTEX_LOCKED(&kthread->startstop_sem); 

/* We need to do a memory barrier here to be sure that 
the flags are visible on all CPUs. 
*/ 
mb(); 

/* set flag to request thread termination */ 
kthread->terminate = 1; 

/* We need to do a memory barrier here to be sure that 
the flags are visible on all CPUs. 
*/ 
mb(); 
kill_proc(kthread->thread->pid, SIGKILL, 1); 

/* block till thread terminated */ 
down(&kthread->startstop_sem); 

/* release the big kernel lock */ 
unlock_kernel(); 

/* now we are sure the thread is in zombie state. We 
notify keventd to clean the process up. 
*/ 
kill_proc(2, SIGCHLD, 1); 

} 

/* initialize new created thread. Called by the new thread. */ 
void init_kthread(kthread_t *kthread, char *name) 
{ 
/* lock the kernel. A new kernel thread starts without 
the big kernel lock, regardless of the lock state 
of the creator (the lock level is *not* inheritated) 
*/ 
lock_kernel(); 

/* fill in thread structure */ 
kthread->thread = current; 

/* set signal mask to what we want to respond */ 
siginitsetinv(&current->blocked, sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM)); 

/* initialise wait queue */ 
init_waitqueue_head(&kthread->queue); 

/* initialise termination flag */ 
kthread->terminate = 0; 

/* set name of this process (max 15 chars + 0 !) */ 
sprintf(current->comm, name); 

/* let others run */ 
unlock_kernel(); 

/* tell the creator that we are ready and let him continue */ 
up(&kthread->startstop_sem); 

} 

/* cleanup of thread. Called by the exiting thread. */ 
void exit_kthread(kthread_t *kthread) 
{ 
/* we are terminating */ 

/* lock the kernel, the exit will unlock it */ 
lock_kernel(); 
kthread->thread = NULL; 
mb(); 

/* notify the stop_kthread() routine that we are terminating. */ 
up(&kthread->startstop_sem); 
/* the kernel_thread that called clone() does a do_exit here. */ 

/* there is no race here between execution of the "killer" and real termination 
of the thread (race window between up and do_exit), since both the 
thread and the "killer" function are running with the kernel lock held. 
The kernel lock will be freed after the thread exited, so the code 
is really not executed anymore as soon as the unload functions gets 
the kernel lock back. 
The init process may not have made the cleanup of the process here, 
but the cleanup can be done safely with the module unloaded. 
*/ 

} 

thread_drv.c 
#include <linux/config.h> 
#include <linux/version.h> 

#include <linux/module.h> 
#if defined(MODVERSIONS) 
#include <linux/modversions.h> 
#endif 

#include <linux/kernel.h> 
#include <linux/string.h> 
#include <linux/errno.h> 
#include <linux/sched.h> 

#include "kthread.h" 

#define NTHREADS 5 

/* the variable that contains the thread data */ 
kthread_t example[NTHREADS]; 

/* prototype for the example thread */ 
static void example_thread(kthread_t *kthread); 

/* load the module */ 
int init_module(void) 
{ 
int i; 

/* create new kernel threads */ 
for (i=0; i <NTHREADS; i++) 
start_kthread(example_thread, &example); 

return(0); 
} 

/* remove the module */ 
void cleanup_module(void) 
{ 
int i; 

/* terminate the kernel threads */ 
for (i=0; i<NTHREADS; i++) 
stop_kthread(&example); 

return; 
} 

/* this is the thread function that we are executing */ 
static void example_thread(kthread_t *kthread) 
{ 
/* setup the thread environment */ 
init_kthread(kthread, "example thread"); 

printk("hi, here is the kernel thread\n"); 

/* an endless loop in which we are doing our work */ 
for(;;) 
{ 
/* fall asleep for one second */ 
interruptible_sleep_on_timeout(&kthread->queue, HZ); 

/* We need to do a memory barrier here to be sure that 
the flags are visible on all CPUs. 
*/ 
mb(); 

/* here we are back from sleep, either due to the timeout 
(one second), or because we caught a signal. 
*/ 
if (kthread->terminate) 
{ 
/* we received a request to terminate ourself */ 
break; 
} 

/* this is normal work to do */ 
printk("example thread: thread woke up\n"); 
} 
/* here we go only in case of termination of the thread */ 

/* cleanup the thread, leave */ 
exit_kthread(kthread); 

/* returning from the thread here calls the exit functions */ 
} 

Makefile 
# set to your kernel tree 
KERNEL = /usr/src/linux 

# get the Linux architecture. Needed to find proper include file for CFLAGS 
ARCH=$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
# set default flags to compile module 
CFLAGS = -D__KERNEL__ -DMODULE -I$(KERNEL)/include 
CFLAGS+= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -fno-strict-aliasing 

all: thread_mod.o 

# get configuration of kernel 
include $(KERNEL)/.config 
# modify CFLAGS with architecture specific flags 
include $(KERNEL)/arch/${ARCH}/Makefile 

# enable the module versions, if configured in kernel source tree 
ifdef CONFIG_MODVERSIONS 
CFLAGS+= -DMODVERSIONS -include $(KERNEL)/include/linux/modversions.h 
endif 
# enable SMP, if configured in kernel source tree 
ifdef CONFIG_SMP 
CFLAGS+= -D__SMP__ 
endif 

# note: we are compiling the driver object file and then linking 
# we link it into the module. With just one object file as in 
# this example this is not needed. We can just load the object 
# file produced by gcc 
# link the thread driver module 
thread_mod.o: thread_drv.o kthread.o 
ld -r -o thread_mod.o thread_drv.o kthread.o 
# compile the kthread object file 
kthread.o: kthread.c kthread.h 
gcc $(CFLAGS) -c kthread.c 
# compile the thread driver 
thread_drv.o: thread_drv.c kthread.h 
gcc $(CFLAGS) -c thread_drv.c 

clean: 
rm -f *.o 

Bugs 
The code assumes that keventd is running with PID 2. 
Comments, Corrections 
Please send comments, corrections etc. to the address below.

from:
http://www.linuxforum.net/forum/showflat.php?Cat=&Board=linuxK&Number=282973&page=15&view=collapsed&sb=5&o=all




chatler 2011-03-22 21:08 鍙戣〃璇勮
]]>
The Linux Kernel Module Programming Guidehttp://m.shnenglu.com/beautykingdom/archive/2010/11/29/134974.htmlchatlerchatlerMon, 29 Nov 2010 04:03:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2010/11/29/134974.htmlhttp://m.shnenglu.com/beautykingdom/comments/134974.htmlhttp://m.shnenglu.com/beautykingdom/archive/2010/11/29/134974.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/134974.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/134974.html闃呰鍏ㄦ枃

chatler 2010-11-29 12:03 鍙戣〃璇勮
]]>
A Beast of a Different Naturehttp://m.shnenglu.com/beautykingdom/archive/2010/05/22/116129.htmlchatlerchatlerSat, 22 May 2010 13:09:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2010/05/22/116129.htmlhttp://m.shnenglu.com/beautykingdom/comments/116129.htmlhttp://m.shnenglu.com/beautykingdom/archive/2010/05/22/116129.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/116129.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/116129.htmllinux kernel development-chapter 2 getting started with the kernel 

A Beast of a Different Nature

The kernel has several differences compared to normal user-space applications that, although not making it necessarily harder to program than user-space, certainly provide unique challenges to kernel development.

These differences make the kernel a beast of a different nature. Some of the usual rules are bent; other rules are entirely new. Although some of the differences are obvious (we all know the kernel can do anything it wants), others are not so obvious. The most important of these differences are

  • The kernel does not have access to the C library.

  • The kernel is coded in GNU C.

  • The kernel lacks memory protection like user-space.

  • The kernel cannot easily use floating point.

  • The kernel has a small fixed-size stack.

  • Because the kernel has asynchronous interrupts, is preemptive, and supports SMP, synchronization and concurrency are major concerns within the kernel.

  • Portability is important.

Let's briefly look at each of these issues because all kernel development must keep them in mind.

No libc

Unlike a user-space application, the kernel is not linked against the standard C library (or any other library, for that matter). There are multiple reasons for this, including some chicken-and-the-egg situations, but the primary reason is speed and size. The full C libraryor even a decent subset of itis too large and too inefficient for the kernel.

Do not fret: Many of the usual libc functions have been implemented inside the kernel. For example, the common string manipulation functions are in lib/string.c. Just include <linux/string.h> and have at them.

Header Files

When I talk about header files hereor elsewhere in this bookI am referring to the kernel header files that are part of the kernel source tree. Kernel source files cannot include outside headers, just as they cannot use outside libraries.


Of the missing functions, the most familiar is printf(). The kernel does not have access to printf(), but it does have access to printk(). The printk() function copies the formatted string into the kernel log buffer, which is normally read by the syslog program. Usage is similar to printf():

printk("Hello world! A string: %s and an integer: %d\n", a_string, an_integer);

One notable difference between printf() and printk() is that printk() allows you to specify a priority flag. This flag is used by syslogd(8) to decide where to display kernel messages. Here is an example of these priorities:

printk(KERN_ERR "this is an error!\n");

We will use printk() tHRoughout this book. Later chapters have more information on printk().

GNU C

Like any self-respecting Unix kernel, the Linux kernel is programmed in C. Perhaps surprisingly, the kernel is not programmed in strict ANSI C. Instead, where applicable, the kernel developers make use of various language extensions available in gcc (the GNU Compiler Collection, which contains the C compiler used to compile the kernel and most everything else written in C on a Linux system).

The kernel developers use both ISO C99[1] and GNU C extensions to the C language. These changes wed the Linux kernel to gcc, although recently other compilers, such as the Intel C compiler, have sufficiently supported enough gcc features that they too can compile the Linux kernel. The ISO C99 extensions that the kernel uses are nothing special and, because C99 is an official revision of the C language, are slowly cropping up in a lot of other code. The more interesting, and perhaps unfamiliar, deviations from standard ANSI C are those provided by GNU C. Let's look at some of the more interesting extensions that may show up in kernel code.

[1] ISO C99 is the latest major revision to the ISO C standard. C99 adds numerous enhancements to the previous major revision, ISO C90, including named structure initializers and a complex type. The latter of which you cannot use safely from within the kernel.

Inline Functions

GNU C supports inline functions. An inline function is, as its name suggests, inserted inline into each function call site. This eliminates the overhead of function invocation and return (register saving and restore), and allows for potentially more optimization because the compiler can optimize the caller and the called function together. As a downside (nothing in life is free), code size increases because the contents of the function are copied to all the callers, which increases memory consumption and instruction cache footprint. Kernel developers use inline functions for small time-critical functions. Making large functions inline, especially those that are used more than once or are not time critical, is frowned upon by the kernel developers.

An inline function is declared when the keywords static and inline are used as part of the function definition. For example:

static inline void dog(unsigned long tail_size)

The function declaration must precede any usage, or else the compiler cannot make the function inline. Common practice is to place inline functions in header files. Because they are marked static, an exported function is not created. If an inline function is used by only one file, it can instead be placed toward the top of just that file.

In the kernel, using inline functions is preferred over complicated macros for reasons of type safety.

Inline Assembly

The gcc C compiler enables the embedding of assembly instructions in otherwise normal C functions. This feature, of course, is used in only those parts of the kernel that are unique to a given system architecture.

The asm() compiler directive is used to inline assembly code.

The Linux kernel is programmed in a mixture of C and assembly, with assembly relegated to low-level architecture and fast path code. The vast majority of kernel code is programmed in straight C.

Branch Annotation

The gcc C compiler has a built-in directive that optimizes conditional branches as either very likely taken or very unlikely taken. The compiler uses the directive to appropriately optimize the branch. The kernel wraps the directive in very easy-to-use macros, likely() and unlikely().

For example, consider an if statement such as the following:

if (foo) {
/* ... */
}

To mark this branch as very unlikely taken (that is, likely not taken):

/* we predict foo is nearly always zero ... */
if (unlikely(foo)) {
/* ... */
}

Conversely, to mark a branch as very likely taken:

/* we predict foo is nearly always nonzero ... */
if (likely(foo)) {
/* ... */
}

You should only use these directives when the branch direction is overwhelmingly a known priori or when you want to optimize a specific case at the cost of the other case. This is an important point: These directives result in a performance boost when the branch is correctly predicted, but a performance loss when the branch is mispredicted. A very common usage for unlikely() and likely() is error conditions. As one might expect, unlikely() finds much more use in the kernel because if statements tend to indicate a special case.

No Memory Protection

When a user-space application attempts an illegal memory access, the kernel can trap the error, send SIGSEGV, and kill the process. If the kernel attempts an illegal memory access, however, the results are less controlled. (After all, who is going to look after the kernel?) Memory violations in the kernel result in an oops, which is a major kernel error. It should go without saying that you must not illegally access memory, such as dereferencing a NULL pointerbut within the kernel, the stakes are much higher!

Additionally, kernel memory is not pageable. Therefore, every byte of memory you consume is one less byte of available physical memory. Keep that in mind next time you have to add one more feature to the kernel!

No (Easy) Use of Floating Point

When a user-space process uses floating-point instructions, the kernel manages the transition from integer to floating point mode. What the kernel has to do when using floating-point instructions varies by architecture, but the kernel normally catches a trap and does something in response.

Unlike user-space, the kernel does not have the luxury of seamless support for floating point because it cannot trap itself. Using floating point inside the kernel requires manually saving and restoring the floating point registers, among possible other chores. The short answer is: Don't do it; no floating point in the kernel.

Small, Fixed-Size Stack

User-space can get away with statically allocating tons of variables on the stack, including huge structures and many-element arrays. This behavior is legal because user-space has a large stack that can grow in size dynamically (developers of older, less intelligent operating systemssay, DOSmight recall a time when even user-space had a fixed-sized stack).

The kernel stack is neither large nor dynamic; it is small and fixed in size. The exact size of the kernel's stack varies by architecture. On x86, the stack size is configurable at compile-time and can be either 4 or 8KB. Historically, the kernel stack is two pages, which generally implies that it is 8KB on 32-bit architectures and 16KB on 64-bit architecturesthis size is fixed and absolute. Each process receives its own stack.

The kernel stack is discussed in much greater detail in later chapters.

Synchronization and Concurrency

The kernel is susceptible to race conditions. Unlike a single-threaded user-space application, a number of properties of the kernel allow for concurrent access of shared resources and thus require synchronization to prevent races. Specifically,

  • Linux is a preemptive multi-tasking operating system. Processes are scheduled and rescheduled at the whim of the kernel's process scheduler. The kernel must synchronize between these tasks.

  • The Linux kernel supports multiprocessing. Therefore, without proper protection, kernel code executing on two or more processors can access the same resource.

  • Interrupts occur asynchronously with respect to the currently executing code. Therefore, without proper protection, an interrupt can occur in the midst of accessing a shared resource and the interrupt handler can then access the same resource.

  • The Linux kernel is preemptive. Therefore, without protection, kernel code can be preempted in favor of different code that then accesses the same resource.

Typical solutions to race conditions include spinlocks and semaphores.

Later chapters provide a thorough discussion of synchronization and concurrency.

Portability Is Important

Although user-space applications do not have to aim for portability, Linux is a portable operating system and should remain one. This means that architecture-independent C code must correctly compile and run on a wide range of systems, and that architecture-dependent code must be properly segregated in system-specific directories in the kernel source tree.

A handful of rulessuch as remain endian neutral, be 64-bit clean, do not assume the word or page size, and so ongo a long way. Portability is discussed in extreme depth in a later chapter.




chatler 2010-05-22 21:09 鍙戣〃璇勮
]]>
HOWTO compile kernel modules for the kernel 2.6http://m.shnenglu.com/beautykingdom/archive/2010/04/14/112591.htmlchatlerchatlerWed, 14 Apr 2010 15:00:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2010/04/14/112591.htmlhttp://m.shnenglu.com/beautykingdom/comments/112591.htmlhttp://m.shnenglu.com/beautykingdom/archive/2010/04/14/112591.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/112591.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/112591.html

If you want to compile the sum-module (source mirrored below), follow these steps:

Create the Makefile in your directory with the sum-module.c

 obj-m    := sum-module.o

KDIR    := /lib/modules/$(shell uname -r)/build

PWD    := $(shell pwd)

default:

       $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

Now do a

 make

... and the sum-module.ko is built.

 If you get something like this

# make

make: Nothing to be done for `default'.

you need to install the kernel source and compile the kernel first (run "make" at least to the point until
 all "HOSTCC scripts/" stuff is done - this will configure your kernel and allows external module compilation).
Make sure /lib/modules/$(shell uname -r)/build points to your build directory (most likely /usr/src/linux...).

Another reason for the above error can be, that your browser converted the TAB before $(MAKE) to spaces.

Make sure there is a TAB before $(MAKE).

Install it with install.sh:

#!/bin/sh

install -m 644 sum-module.ko /lib/modules/`uname -r`/kernel/drivers/sum-module.ko

/sbin/depmod -a (adjust the /lib/modules path according to your needs)

 Now make a

# modprobe sum-module

Or if you don't want to install the module, do this:

# insmod ./sum-module.ko

..and if your system doesn't freeze you've done it right ;-)

 

For kernel 2.4, the Makefile would look like this:

TARGET       := modulename

INCLUDE    := -I/lib/modules/`uname -r`/build/include

CFLAGS      := -O2 -Wall -DMODULE -D__KERNEL__ -DLINUX

CC  := gcc ${TARGET}.o: ${TARGET}.c

       $(CC) $(CFLAGS) ${INCLUDE} -c ${TARGET}.c

 (not yet tested)

sum-module source from: http://www.win.tue.nl/~aeb/linux/lk/lk-9.html

/*

 * sum-module.c

# modprobe sum-module.o

# ls -l /proc/arith

total 0

dr-xr-xr-x    2 root     root            0 Sep 30 12:40 .

dr-xr-xr-x   89 root     root            0 Sep 30 12:39 ..

-r--r--r--    1 root     root            0 Sep 30 12:40 sum

# cat /proc/arith/sum

0

# echo 7 > /proc/arith/sum

# echo 5 > /proc/arith/sum

# echo 13 > /proc/arith/sum

# cat /proc/arith/sum

25

# rmmod sum-module

# ls -l /proc/arith

ls: /proc/arith: No such file or directory

#

*/

#include <linux/module.h>

#include <linux/init.h>

#include <linux/proc_fs.h>

#include <asm/uaccess.h>

static unsigned long long sum;

static int show_sum(char *buffer, char **start, off_t offset, int length) {

        int size;

     size = sprintf(buffer, "%lld\n", sum);

        *start = buffer + offset;

        size -= offset;

   return (size > length) ? length : (size > 0) ? size : 0;

}

/* Expect decimal number of at most 9 digits followed by '\n' */

static int add_to_sum(struct file *file, const char *buffer,

                      unsigned long count, void *data)

{

        unsigned long val = 0;

        char buf[10];

       char *endp;

        if (count > sizeof(buf))

                return -EINVAL;

        if (copy_from_user(buf, buffer, count))

                return -EFAULT;

        val = simple_strtoul(buf, &endp, 10);

        if (*endp != '\n')

                return -EINVAL;


        sum += val;     /* mod 2^64 */

        return count;

}

 

static int __init sum_init(void) {

        struct proc_dir_entry *proc_arith;

        struct proc_dir_entry *proc_arith_sum;

        proc_arith = proc_mkdir("arith", 0);

        if (!proc_arith) {

                printk (KERN_ERR "cannot create /proc/arith\n");

                return -ENOMEM;

        }

        proc_arith_sum = create_proc_info_entry("arith/sum", 0, 0, show_sum);

        if (!proc_arith_sum) {

                printk (KERN_ERR "cannot create /proc/arith/sum\n");

                remove_proc_entry("arith", 0);

                return -ENOMEM;

        }

        proc_arith_sum->write_proc = add_to_sum;

        return 0;

}

 

static void __exit sum_exit(void) {

        remove_proc_entry("arith/sum", 0);

        remove_proc_entry("arith", 0);

}

module_init(sum_init);

module_exit(sum_exit);

MODULE_LICENSE("GPL");

 

 from錛?/font>

http://www.captain.at/programming/kernel-2.6/

http://blog.ednchina.com/fafen/267973/message.aspx


chatler 2010-04-14 23:00 鍙戣〃璇勮
]]>
Linux鍐呮牳涓殑涓浜涘熀鏈紪紼嬫搷浣?/title><link>http://m.shnenglu.com/beautykingdom/archive/2010/04/01/111316.html</link><dc:creator>chatler</dc:creator><author>chatler</author><pubDate>Thu, 01 Apr 2010 11:59:00 GMT</pubDate><guid>http://m.shnenglu.com/beautykingdom/archive/2010/04/01/111316.html</guid><wfw:comment>http://m.shnenglu.com/beautykingdom/comments/111316.html</wfw:comment><comments>http://m.shnenglu.com/beautykingdom/archive/2010/04/01/111316.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/beautykingdom/comments/commentRss/111316.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/beautykingdom/services/trackbacks/111316.html</trackback:ping><description><![CDATA[<div>鏈枃妗g殑Copyleft褰抷fydz鎵鏈夛紝浣跨敤GPL鍙戝竷錛屽彲浠ヨ嚜鐢辨嫹璐濓紝杞澆錛岃漿杞芥椂璇蜂繚鎸佹枃妗g殑瀹屾暣鎬э紝涓ョ鐢ㄤ簬浠諱綍鍟嗕笟鐢ㄩ斻?br>msn: <a href="mailto:yfydz_no1@hotmail.com"><u><font color="#0000ff">yfydz_no1@hotmail.com</font></u></a><br>鏉ユ簮錛?a ><u><font color="#0000ff">http://yfydz.cublog.cn</font></u></a></div> <div><br>1. 鍓嶈█</div> <div> </div> <div>鏈枃浠嬬粛linux鍐呮牳涓竴浜涘父鐢ㄧ殑鏁版嵁緇撴瀯鍜屾搷浣溿?/div> <div> </div> <div>2. 鍙屽悜閾捐〃(list)</div> <div> </div> <div>linux鍐呮牳涓殑鍙屽悜閾捐〃閫氳繃緇撴瀯 struct list_head鏉ュ皢鍚勪釜鑺傜偣榪炴帴璧鋒潵錛屾緇撴瀯浼氫綔涓洪摼琛ㄥ厓绱犵粨鏋勪腑鐨勪竴涓弬鏁幫細</div> <div>struct list_head {<br> struct list_head *next, *prev;<br>};</div> <div> </div> <div>閾捐〃澶寸殑鍒濆鍖栵紝娉ㄦ剰錛岀粨鏋勪腑鐨勬寚閽堜負NULL騫朵笉鏄垵濮嬪寲錛岃屾槸鎸囧悜鑷韓鎵嶆槸鍒濆鍖栵紝濡傛灉鍙槸鎸夋櫘閫氭儏鍐典笅鐨勭疆涓篘ULL錛岃屼笉鏄寚鍚戣嚜韜紝緋葷粺浼氬穿婧冿紝榪欐槸涓涓鏄撶姱鐨勯敊璇細</div> <div> </div> <div>#define LIST_HEAD_INIT(name) { &(name), &(name) }</div> <div>#define LIST_HEAD(name) \<br> struct list_head name = LIST_HEAD_INIT(name)</div> <div>#define INIT_LIST_HEAD(ptr) do { \<br> (ptr)->next = (ptr); (ptr)->prev = (ptr); \<br>} while (0)</div> <div> </div> <div>鏈甯哥敤鐨勯摼琛ㄦ搷浣滐細</div> <div>鎻掑叆鍒伴摼琛ㄥご:<br>void list_add(struct list_head *new, struct list_head *head);</div> <div> </div> <div>鎻掑叆鍒伴摼琛ㄥ熬:<br>void list_add_tail(struct list_head *new, struct list_head *head);</div> <div> </div> <div>鍒犻櫎閾捐〃鑺傜偣:<br>void list_del(struct list_head *entry);</div> <div> </div> <div>灝嗚妭鐐圭Щ鍔ㄥ埌鍙︿竴閾捐〃:<br>void list_move(struct list_head *list, struct list_head *head);</div> <div> </div> <div>灝嗚妭鐐圭Щ鍔ㄥ埌閾捐〃灝?<br>void list_move_tail(struct list_head *list,struct list_head *head);</div> <div> </div> <div>鍒ゆ柇閾捐〃鏄惁涓虹┖錛岃繑鍥?涓虹┖錛?闈炵┖<br>int list_empty(struct list_head *head);</div> <div> </div> <div>鎶婁袱涓摼琛ㄦ嫾鎺ヨ搗鏉ワ細<br>void list_splice(struct list_head *list, struct list_head *head)錛?/div> <div> </div> <div>鍙栧緱鑺傜偣鎸囬拡錛?br>#define list_entry(ptr, type, member) \<br> ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))</div> <div> </div> <div>閬嶅巻閾捐〃涓瘡涓妭鐐癸細<br>#define list_for_each(pos, head) \<br> for (pos = (head)->next, prefetch(pos->next); pos != (head); \<br>         pos = pos->next, prefetch(pos->next))</div> <div> </div> <div>閫嗗悜寰幆閾捐〃涓瘡涓妭鐐癸細<br>#define list_for_each_prev(pos, head) \<br> for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \<br>         pos = pos->prev, prefetch(pos->prev))</div> <div> </div> <div>涓句緥錛?/div> <div> </div> <div>LISH_HEAD(mylist);</div> <div> </div> <div>struct my_list{<br> struct list_head list;<br> int data;<br>};</div> <div> </div> <div>static int ini_list(void)<br>{<br> struct my_list *p;<br> int i;<br> for(i=0; i<100; i++){<br>  p=kmalloc(sizeof(struct my_list), GFP_KERNEL);<br>  list_add(&p->list, &mylist);<br> }<br>}</div> <div><br>鍦ㄥ唴瀛樹腑褰㈡垚濡備笅緇撴瀯鐨勪竴涓弻鍚戦摼琛細</div> <div> </div> <div>  +---------------------------------------------------------------+<br>  |                                                               |<br>  |  mylist         99            98                     0        |<br>  |  +----+    +---------+    +---------+           +---------+   |<br>  +->|next|--->|list.next|--->|list.next|--->...--->|list.next|---+<br>     |----|    |---------|    |---------|           |---------|<br>  +--|prev|<---|list.prev|<---|list.prev|<---...<---|list.prev|<--+<br>  |  +----+    |---------|    |---------|           |---------|   |<br>  |            |  data   |    |  data   |           |  data   |   |<br>  |            +---------+    +---------+           +---------+   |<br>  |                                                               |<br>  +---------------------------------------------------------------+</div> <div> </div> <div>鐭ラ亾浜嗛摼琛ㄥご灝辮兘閬嶅巻鏁翠釜閾捐〃錛屽鏋滄槸鐢╨ist_add()鎻掑叆鏂拌妭鐐圭殑璇濓紝浠庨摼琛ㄥご鐨刵ext鏂瑰悜鐪嬫槸涓涓爢鏍堝瀷銆?/div> <div> </div> <div>浠庨摼琛ㄤ腑鍒犻櫎鑺傜偣寰堝鏄擄細</div> <div>static void del_item(struct my_list *p)<br>{<br> list_del(&p->list, &mylist);<br> kfree(p);<br>}</div> <div> </div> <div>鏈閲嶈鐨勫畯鏄痩ist_entry錛岃繖涓畯鐨勬濊礬鏄牴鎹摼琛ㄥ厓绱犵粨鏋勪腑閾捐〃澶寸粨鏋刲ist_head鐨勫湴鍧鎺ㄧ畻鍑洪摼琛ㄥ厓绱犵粨鏋勭殑瀹為檯鍦板潃錛?/div> <div> </div> <div>#define list_entry(ptr, type, member) \<br> ((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))</div> <div> </div> <div>ptr鏄摼琛ㄥ厓绱犵粨鏋?濡俿truct my_list)涓摼琛ㄥご緇撴瀯list_head鐨勫湴鍧<br>member鏄摼琛ㄥ厓绱犵粨鏋?濡俿truct my_list)涓摼琛ㄥご緇撴瀯list_head鍙傛暟鐨勫悕縐?br>type鏄摼琛ㄥ厓绱犵粨鏋勭被鍨?濡俿truct my_list)<br></div> <div>璁$畻鍘熺悊鏄牴鎹摼琛ㄥご緇撴瀯list_head鐨勫湴鍧鍑忓幓鍏跺湪閾捐〃鍏冪礌緇撴瀯涓殑鍋忕Щ浣嶇疆鑰屽緱鍒伴摼琛ㄥ厓绱犵粨鏋勭殑鍦板潃銆?/div> <div> </div> <div>渚嬪錛?/div> <div>static void print_list(void)<br>{<br> struct list_head *cur;<br> struct my_list *p;</div> <div> list_for_each(cur, &mylist){<br>  p=list_entry(cur, struct my_list, list);<br>  printk("data=%d\n", p->data);<br> }<br>}</div> <div> </div> <div>浼樼偣錛?br></div> <div>榪欐牱灝卞彲浠ョ敤鐩稿悓鐨勬暟鎹鐞嗘柟寮忔潵鎻忚堪鎵鏈夊弻鍚戦摼琛紝涓嶇敤鍐嶅崟鐙負鍚勪釜閾捐〃緙栧啓鍚勭緙栬緫鍑芥暟銆?/div> <div> </div> <div>緙虹偣錛?br>1) 閾捐〃澶翠腑鍏冪礌緗負NULL涓嶆槸鍒濆鍖栵紝涓庢櫘閫氫範鎯笉鍚岋紱<br>2) 浠嶇劧闇瑕佸崟鐙紪鍐欏悇鑷殑鍒犻櫎鏁翠釜閾捐〃鐨勫嚱鏁幫紝涓嶈兘緇熶竴澶勭悊錛屽洜涓轟笉鑳戒繚璇佹墍鏈夐摼琛ㄥ厓绱犵粨鏋勪腑閾捐〃澶寸粨鏋刲ist_head鐨勫亸縐誨湴鍧閮芥槸鐩稿悓鐨勶紝褰撶劧濡傛灉鎶婇摼琛ㄥご緇撴瀯list_head閮戒綔涓洪摼琛ㄥ厓绱犵粨鏋勭殑絎竴涓弬鏁幫紝灝卞彲浠ョ敤緇熶竴鐨勫垹闄ゆ暣涓摼琛ㄧ殑鍑芥暟銆?/div> <div><br>3. HASH琛?/div> <div> </div> <div>HASH琛ㄩ傜敤浜庝笉闇瑕佸鏁翠釜絀洪棿鍏冪礌榪涜鎺掑簭錛岃屾槸鍙渶瑕佽兘蹇熸壘鍒版煇涓厓绱犵殑鍦哄悎錛屾槸涓縐嶄互絀洪棿鎹㈡椂闂寸殑鏂規(guī)硶錛屾湰璐ㄤ篃鏄嚎鎬ц〃錛屼絾鐢變竴涓ぇ鐨勭嚎鎬ц〃鎷嗗垎涓轟簡澶氫釜灝忕嚎鎬ц〃錛岀敱浜庡彧闇瑕佹煡鎵懼皬琛紝鍥犳鎼滅儲閫熷害灝變細綰挎ф煡鏁翠釜澶ц〃鎻愰珮寰堝錛岀悊鎯蟲儏鍐典笅錛屾湁澶氬皯涓皬綰挎ц〃錛屾悳绱㈤熷害灝辨彁楂樹簡澶氬皯鍊嶏紝閫氬父鎶婂皬綰挎ц〃鐨勮〃澶寸患鍚堜負涓涓暟緇勶紝澶у皬灝辨槸HASH琛ㄧ殑鏁伴噺銆?/div> <div> </div> <div>HASH琛ㄩ熷害鐨勫叧閿槸HASH鍑芥暟鐨勮璁★紝HASH鍑芥暟鏍規(guī)嵁姣忎釜鍏冪礌涓浐瀹氱殑鍙傛暟榪涜璁$畻錛岀畻鍑轟竴涓笉澶т簬HASH琛ㄦ暟閲忕殑绱㈠紩鍊鹼紝琛ㄧず璇ュ厓绱犻渶瑕佹斁鍦ㄨ绱㈠紩鍙峰搴旂殑閭d釜琛ㄤ腑錛屽浜庡浐瀹氱殑鍙傛暟錛岃綆楃粨鏋滃緇堟槸鍥哄畾鐨勶紝浣嗗浜庝笉鍚岀殑鍙傛暟鍊鹼紝甯屾湜璁$畻鍑烘潵鐨勭粨鏋滆兘灝藉彲鑳藉湴騫沖潎鍒版瘡涓儲寮曞鹼紝HASH鍑芥暟璁$畻寰楄秺騫沖潎錛岃〃紺烘瘡涓皬琛ㄤ腑鍏冪礌鐨勬暟閲忛兘浼氬樊涓嶅錛岃繖鏍鋒悳绱㈡ц兘灝嗚秺濂姐?span style="color: red;">HASH鍑芥暟涔熻灝藉彲鑳界殑綆鍗曪紝浠ュ噺灝戣綆楁椂闂達紝甯哥敤鐨勭畻娉曟槸灝嗗弬鏁扮瘡鍔犳眰妯?/span>錛屽湪include/linux/jhash.h涓凡緇忓畾涔変簡涓浜汬ASH璁$畻鍑芥暟錛屽彲鐩存帴浣跨敤銆?/div> <div> </div> <div style="color: red;">HASH琛ㄥ湪璺敱cache琛紝鐘舵佽繛鎺ヨ〃絳夊鐢ㄥ緱寰堝銆?/div> <div> </div> <div>涓句緥錛岃繛鎺ヨ窡韙腑鏍規(guī)嵁tuple鍊艱綆桯ASH錛?/div> <div>// net/ipv4/netfilter/ip_conntrack_core.c</div> <div>u_int32_t<br>hash_conntrack(const struct ip_conntrack_tuple *tuple)<br>{<br>#if 0<br> dump_tuple(tuple);<br>#endif<br> return (jhash_3words(tuple->src.ip,<br>                      (tuple->dst.ip ^ tuple->dst.protonum),<br>                      (tuple->src.u.all | (tuple->dst.u.all << 16)),<br>                      ip_conntrack_hash_rnd) % ip_conntrack_htable_size);<br>}</div> <div> </div> <div>// include/linux/jhash.h<br>static inline u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval)<br>{<br> a += JHASH_GOLDEN_RATIO;<br> b += JHASH_GOLDEN_RATIO;<br> c += initval;</div> <div> __jhash_mix(a, b, c);</div> <div> return c;<br>}</div> <div> </div> <div>4. 瀹氭椂鍣?timer)</div> <div> </div> <div>linux鍐呮牳瀹氭椂鍣ㄧ敱浠ヤ笅緇撴瀯鎻忚堪錛?/div> <div> </div> <div>/* include/linux/timer.h */<br>struct timer_list {<br> struct list_head list;<br> unsigned long expires;<br> unsigned long data;<br> void (*function)(unsigned long);<br>};<br></div> <div>list錛歵imer閾捐〃<br>expires錛氬埌鏈熸椂闂?br>function錛氬埌鏈熷嚱鏁幫紝鏃墮棿鍒版湡鏃惰皟鐢ㄧ殑鍑芥暟<br>data錛氫紶緇欏埌鏈熷嚱鏁扮殑鏁版嵁錛屽疄闄呭簲鐢ㄤ腑閫氬父鏄竴涓寚閽堣漿鍖栬屾潵錛岃鎸囬拡鎸囧悜涓涓粨鏋?/div> <div><br>timer鐨勬搷浣滐細</div> <div> </div> <div>澧炲姞timer錛屽皢timer鎸傛帴鍒扮郴緇熺殑timer閾捐〃錛?br>extern void add_timer(struct timer_list * timer);</div> <div> </div> <div>鍒犻櫎timer錛屽皢timer浠庣郴緇焧imer閾捐〃涓媶闄わ細<br>extern int del_timer(struct timer_list * timer);<br>(del_timer()鍑芥暟鍙兘浼氬け璐ワ紝榪欐槸鍥犱負璇imer鏈潵宸茬粡涓嶅湪緋葷粺timer閾捐〃涓簡錛屼篃灝辨槸宸茬粡鍒犻櫎榪囦簡)</div> <div> </div> <div>瀵逛簬SMP緋葷粺錛屽垹闄imer鏈濂戒嬌鐢ㄤ笅闈㈢殑鍑芥暟鏉ラ槻姝㈠啿紿侊細<br>extern int del_timer_sync(struct timer_list * timer);</div> <div> </div> <div>淇敼timer錛屼慨鏀箃imer鐨勫埌鏈熸椂闂達細<br>int mod_timer(struct timer_list *timer, unsigned long expires);</div> <div> </div> <div>閫氬父鐢ㄦ硶錛?br><span style="color: red;">    struct timer_list閫氬父浣滀負鏁版嵁緇撴瀯涓殑涓涓弬鏁幫紝鍦ㄥ垵濮嬪寲緇撴瀯鐨勬椂鍊欏垵濮嬪寲timer錛岃〃紺哄埌鏈熸椂瑕佽繘琛岀殑鎿嶄綔錛屽疄鐜板畾鏃跺姩浣滐紝閫氬父鏇村鐨勬槸浣滀負瓚呮椂澶勭悊鐨勶紝timer鍑芥暟浣滀負瓚呮椂鏃剁殑璧勬簮閲婃斁鍑芥暟銆傛敞鎰忥細濡傛灉瓚呮椂浜嗚繍琛岃秴鏃跺嚱鏁幫紝姝ゆ椂緋葷粺鏄鍦ㄦ椂閽熶腑鏂殑bottom half閲岀殑錛屼笉鑳借繘琛屽緢澶嶆潅鐨勬搷浣滐紝濡傛灉瑕佸畬鎴愪竴浜涘鏉傛搷浣滐紝濡傚埌鏈熷悗鐨勬暟鎹彂閫侊紝涓嶈兘鐩存帴鍦ㄥ埌鏈熷嚱鏁頒腑澶勭悊錛岃屾槸搴旇鍦ㄥ埌鏈熷嚱鏁頒腑鍙戜釜淇″彿緇欑壒瀹氬唴鏍哥嚎紼嬭漿鍒皌op half榪涜澶勭悊銆?/span></div> <div> </div> <div>涓哄垽鏂椂闂寸殑鍏堝悗錛屽唴鏍鎬腑瀹氫箟浜嗕互涓嬪畯鏉ュ垽鏂細</div> <div>#define time_after(a,b)  ((long)(b) - (long)(a) < 0)<br>#define time_before(a,b) time_after(b,a)</div> <div>#define time_after_eq(a,b) ((long)(a) - (long)(b) >= 0)<br>#define time_before_eq(a,b) time_after_eq(b,a)</div> <div>榪欓噷鐢ㄥ埌浜嗕竴涓妧宸э紝<span style="color: red;">鐢變簬linux涓殑鏃墮棿鏄棤絎﹀彿鏁幫紝榪欓噷鍏堝皢鍏惰漿鎹負鏈夌鍙鋒暟鍚庡啀鍒ゆ柇錛屽氨鑳借В鍐蟲椂闂村洖緇曢棶棰橈紝褰撶劧鍙槸涓嬈″洖緇曪紝鍥炵粫涓ゆ褰撶劧鏄垽鏂笉鍑烘潵鐨勶紝鍏蜂綋鍙嚜宸卞疄楠屼綋浼氥?/span></div> <div> </div> <div>5. 鍐呮牳綰跨▼(kernel_thread)</div> <div> </div> <div>鍐呮牳涓柊綰跨▼鐨勫緩绔嬪彲浠ョ敤kernel_thread鍑芥暟瀹炵幇錛岃鍑芥暟鍦╧ernel/fork.c涓畾涔夛細</div> <div>long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)</div> <div>fn錛氬唴鏍哥嚎紼嬩富鍑芥暟錛?br>arg錛氱嚎紼嬩富鍑芥暟鐨勫弬鏁幫紱<br>flags錛氬緩绔嬬嚎紼嬬殑鏍囧織錛?/div> <div> </div> <div>鍐呮牳綰跨▼鍑芥暟閫氬父閮借皟鐢╠aemonize()榪涜鍚庡彴鍖栦綔涓轟竴涓嫭绔嬬殑綰跨▼榪愯錛岀劧鍚庤緗嚎紼嬬殑涓浜涘弬鏁幫紝濡傚悕縐幫紝淇″彿澶勭悊絳夛紝榪欎篃涓嶆槸蹇呴』鐨勶紝鐒跺悗灝辮繘鍏ヤ竴涓寰幆錛岃繖鏄嚎紼嬬殑涓諱綋閮ㄥ垎錛岃繖涓驚鐜笉鑳戒竴鐩村湪榪愯錛屽惁鍒欑郴緇熷氨姝誨湪榪欎簡錛屾垨鑰呮槸鏌愮浜嬩歡椹卞姩鐨勶紝鍦ㄤ簨浠跺埌鏉ュ墠鏄潯鐪犵殑錛屼簨浠跺埌鏉ュ悗鍞ら啋榪涜鎿嶄綔錛屾搷浣滃畬鍚庣戶緇潯鐪狅紱鎴栬呮槸瀹氭椂鐫$湢錛岄啋鍚庢搷浣滃畬鍐嶇潯鐪狅紱鎴栬呭姞鍏ョ瓑寰呴槦鍒楅氳繃schedule()璋冨害鑾峰緱鎵ц鏃墮棿銆傛諱箣鏄笉鑳戒竴鐩村崰鐫 CPU銆?/div> <div> </div> <div>浠ヤ笅鏄唴鏍哥嚎紼嬬殑涓涓疄渚嬶紝鍙栬嚜kernel/context.c:</div> <div> </div> <div>int start_context_thread(void)<br>{<br> static struct completion startup __initdata = COMPLETION_INITIALIZER(startup);</div> <div> kernel_thread(context_thread, &startup, CLONE_FS | CLONE_FILES);<br> wait_for_completion(&startup);<br> return 0;<br>}</div> <div>static int context_thread(void *startup)<br>{<br> struct task_struct *curtask = current;<br> DECLARE_WAITQUEUE(wait, curtask);<br> struct k_sigaction sa;</div> <div> daemonize();<br> strcpy(curtask->comm, "keventd");<br> keventd_running = 1;<br> keventd_task = curtask;</div> <div> spin_lock_irq(&curtask->sigmask_lock);<br> siginitsetinv(&curtask->blocked, sigmask(SIGCHLD));<br> recalc_sigpending(curtask);<br> spin_unlock_irq(&curtask->sigmask_lock);</div> <div> complete((struct completion *)startup);</div> <div> /* Install a handler so SIGCLD is delivered */<br> sa.sa.sa_handler = SIG_IGN;<br> sa.sa.sa_flags = 0;<br> siginitset(&sa.sa.sa_mask, sigmask(SIGCHLD));<br> do_sigaction(SIGCHLD, &sa, (struct k_sigaction *)0);</div> <div> /*<br>  * If one of the functions on a task queue re-adds itself<br>  * to the task queue we call schedule() in state TASK_RUNNING<br>  */<br> for (;;) {<br>  set_task_state(curtask, TASK_INTERRUPTIBLE);<br>  add_wait_queue(&context_task_wq, &wait);<br>  if (TQ_ACTIVE(tq_context))<br>   set_task_state(curtask, TASK_RUNNING);<br>  schedule();<br>  remove_wait_queue(&context_task_wq, &wait);<br>  run_task_queue(&tq_context);<br>  wake_up(&context_task_done);<br>  if (signal_pending(curtask)) {<br>   while (waitpid(-1, (unsigned int *)0, __WALL|WNOHANG) > 0)<br>    ;<br>   spin_lock_irq(&curtask->sigmask_lock);<br>   flush_signals(curtask);<br>   recalc_sigpending(curtask);<br>   spin_unlock_irq(&curtask->sigmask_lock);<br>  }<br> }<br>}</div> <div> </div> <div>6. 緇撴瀯鍦板潃</div> <div> </div> <div>鍦–涓紝緇撴瀯鍦板潃鍜岀粨鏋勪腑絎竴涓厓绱犵殑鍦板潃鏄浉鍚岀殑錛屽洜姝ゅ湪linux鍐呮牳涓粡甯稿嚭鐜頒嬌鐢ㄧ粨鏋勭涓涓厓绱犵殑鍦板潃鏉ヨ〃紺虹粨鏋勫湴鍧鐨勬儏鍐碉紝鍦ㄨ浠g爜鏃惰娉ㄦ剰榪欎竴鐐癸紝榪欏拰list_entry瀹忕殑鎰忔濅竴鏍楓?/div> <div> </div> <div>濡傦細<br>struct my_struct{<br> int a;<br> int b;<br>}c;</div> <div>if(&c == &c.a){  // always true<br>...<br>}<br><br><br><br>from:<br><br><a >http://blog.chinaunix.net/u/12313/showart_109612.html</a></div><img src ="http://m.shnenglu.com/beautykingdom/aggbug/111316.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/beautykingdom/" target="_blank">chatler</a> 2010-04-01 19:59 <a href="http://m.shnenglu.com/beautykingdom/archive/2010/04/01/111316.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>濡備綍鍦↙inux鍐呮牳涓啓鏂囦歡http://m.shnenglu.com/beautykingdom/archive/2010/02/27/108529.htmlchatlerchatlerSat, 27 Feb 2010 03:02:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2010/02/27/108529.htmlhttp://m.shnenglu.com/beautykingdom/comments/108529.htmlhttp://m.shnenglu.com/beautykingdom/archive/2010/02/27/108529.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/108529.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/108529.html#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/string.h>
#include <linux/mm.h>
#include <linux/syscalls.h>
#include <asm/unistd.h>
#include <asm/uaccess.h>

#define MY_FILE "/root/LogFile"

char buf[128];
struct file *file = NULL;

static int __init init(void)
{
        mm_segment_t old_fs;
        printk("Hello, I'm the module that intends to write messages to file.\n");


        if(file == NULL)
                file = filp_open(MY_FILE, O_RDWR | O_APPEND | O_CREAT, 0644);
        if (IS_ERR(file)) {
                printk("error occured while opening file %s, exiting...\n", MY_FILE);
                return 0;
        }

        sprintf(buf,"%s", "The Messages.");

        old_fs = get_fs();
        set_fs(KERNEL_DS);
        file->f_op->write(file, (char *)buf, sizeof(buf), &file->f_pos);
        set_fs(old_fs);


        return 0;
}

static void __exit fini(void)
{
        if(file != NULL)
                filp_close(file, NULL);
}

module_init(init);
module_exit(fini);
MODULE_LICENSE("GPL");


from錛?br>http://blog.csdn.net/coofive/archive/2006/05/07/712028.aspx

chatler 2010-02-27 11:02 鍙戣〃璇勮
]]>
What is the difference between user level threads and kernel level threads?http://m.shnenglu.com/beautykingdom/archive/2010/02/27/108526.htmlchatlerchatlerSat, 27 Feb 2010 02:00:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2010/02/27/108526.htmlhttp://m.shnenglu.com/beautykingdom/comments/108526.htmlhttp://m.shnenglu.com/beautykingdom/archive/2010/02/27/108526.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/108526.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/108526.html

A kernel thread, sometimes called a LWP (Lightweight Process) is created and scheduled by the kernel. Kernel threads are often more expensive to create than user threads and the system calls to directly create kernel threads are very platform specific.

A user thread is normally created by a threading library and scheduling is managed by the threading library itself (Which runs in user mode). All user threads belong to process that created them. The advantage of user threads is that they are portable.

The major difference can be seen when using multiprocessor systems, user threads completely managed by the threading library can't be ran in parallel on the different CPUs, although this means they will run fine on uniprocessor systems. Since kernel threads use the kernel scheduler, different kernel threads can run on different CPUs.

Many systems implement threading differently,

A many-to-one threading model maps many user processes directly to one kernel thread, the kernel thread can be thought of as the main process.

A one-to-one threading model maps each user thread directly to one kernel thread, this model allows parallel processing on the multiprocessor systems. Each kernel thread can be thought of as a VP (Virtual Process) which is managed by the scheduler.


from:
http://blog.csdn.net/jicheng687/archive/2009/09/08/4527676.aspx




chatler 2010-02-27 10:00 鍙戣〃璇勮
]]>
Linux 鍐呮牳絎旇2 鈥?榪涚▼璋冨害http://m.shnenglu.com/beautykingdom/archive/2010/02/15/107892.htmlchatlerchatlerMon, 15 Feb 2010 07:30:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2010/02/15/107892.htmlhttp://m.shnenglu.com/beautykingdom/comments/107892.htmlhttp://m.shnenglu.com/beautykingdom/archive/2010/02/15/107892.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/107892.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/107892.html1 鍓嶈█
2 璋冨害綆楁硶
2.1.1 甯哥敤姒傚康
2.1.2 榪涚▼鏁版嵁緇撴瀯涓浉鍏沖唴瀹?
2.1.3 璋冨害綆楁硶璇存槑
2.1.4 鐩稿叧鍑芥暟
3 璋冨害紼嬪簭鐨勬墽琛?
3.1.1 鐩存帴璋冪敤
3.1.2 寤惰繜璋冪敤
3.1.3 鐩稿叧鍑芥暟
4 榪涚▼璋冨害紺烘剰鍥?
5 SMP緋葷粺鐨勮皟搴?
6 闂涓庣瓟妗?
7 鍙傝冩枃鐚細

1 鍓嶈█
鏈枃鐨勮鍙崗璁伒寰狦NU Free Document License銆傚崗璁殑鍏蜂綋鍐呭璇峰弬瑙乭ttp://www.gnu.org/copyleft/fdl.html銆傚湪閬靛驚GNU Free Document License鐨勫熀紜涓婏紝鍙互鑷敱鍦頒紶鎾垨鍙戣鏈枃錛屼絾璇蜂繚鐣欐湰鏂囩殑瀹屾暣鎬с?
嬈㈣繋澶у瀵硅繖綃囨枃绔犳彁鍑烘剰瑙佸拰鎸囨錛屾垜鐨別mail鏄細shisheng_liu@yahoo.com.cn銆?

2 璋冨害綆楁硶
2.1.1 甯哥敤姒傚康
2.1.1.1 瀹氭椂涓柇
閫氳繃紜歡鐨勫彲緙栫▼涓柇鎺у埗鍣?254鏉ュ疄鐜幫紝瀹氭椂涓柇鍙戠敓鐨勯鐜囩敱HZ瀹氫箟錛屽彂鐢熺殑鏃墮棿闂撮殧琚О涓簍ick銆?
2.1.1.2 CPU鑺傛媿錛坱ick錛?
璁$畻鏈哄唴閮ㄦ椂闂寸殑涓涓鏁板崟浣嶏紝琛ㄧず鍙戠敓涓嬈℃椂閽熶腑鏂殑鏃墮棿闂撮殧銆?
2.1.1.3 HZ
鏃墮挓涓柇鍙戠敓鐨勯鐜囥傚湪i386鏈哄櫒涓婏紝HZ琚畾涔変負100錛屽洜姝ゆ椂閽熶腑鏂瘡10ms涓嬈°?
2.1.1.4 CPU鏃舵湡
璋冨害鏄互CPU鏃舵湡涓哄懆鏈熺殑錛屽湪涓涓狢PU鏃舵湡/璋冨害鍛ㄦ湡鍐咃紝緋葷粺涓墍鏈夌▼搴忛兘琚墽琛岀洿鍒扮敤瀹屽綋鍓嶇殑鏃墮棿鐗囷紝鐒跺悗鎵鏈夎繘紼嬬殑counter鍊艱閲嶆柊璁$畻錛屽茍寮濮嬪彟涓涓狢PU鏃舵湡銆?
2.1.1.5 榪涚▼鐨勫垎綾?
鍦ㄨ皟搴︾▼搴忕湅鏉ワ紝緋葷粺涓殑榪涚▼鍒嗕負涓ゅぇ綾伙紝鍒嗗埆鏄疄鏃惰繘紼嬪拰鏅氳繘紼嬨傚湪浠諱綍鏃跺欏疄鏃惰繘紼嬬殑鎵ц閮介珮浜庢櫘閫氳繘紼嬨傝繘紼嬫暟鎹粨鏋勪腑鐨刾olicy鎴? 鍛樺彉閲忚〃紺轟簡榪涚▼鏄摢涓綾伙紝鑰宻ched_set(/get)scheduler鎻愪緵浜嗘帶鍒惰繘紼嬭皟搴olicy鐨勭敤鎴風駭緙栫▼鎺ュ彛銆?
2.1.2 榪涚▼鏁版嵁緇撴瀯涓浉鍏沖唴瀹?
2.1.2.1 1錛巒ice
榪涚▼鐨勪紭鍏堢駭錛屽獎鍝嶈繘紼嬭幏寰桟PU浜嬩歡鐨勫灝戯紝20涓烘渶浣庯紝-19涓烘渶楂樸?
2.1.2.2 2錛巆ounter
榪涚▼鏃墮棿鐗囨墍鍓╀綑鐨凜PU鑺傛媿鏁般傚垵濮嬪兼牴鎹繘紼嬬殑nice鍊煎喅瀹氾紝鍦ㄦ瘡嬈℃椂閽熶腑鏂彂鐢熸椂錛屼篃灝辨槸涓涓狢PU鑺傛媿錛坱ick錛夌殑鏃跺欙紝褰撳墠榪涚▼鐨刢ounter鍊煎噺1錛屽鏋渃ounter鍊煎彉涓?鍒欒〃紺哄綋鍓嶈繘紼嬬殑鏃墮棿鐗囧凡緇忕敤瀹岋紝緋葷粺浼氶噸鏂拌皟搴︼紝鍐沖畾涓嬩竴涓墽琛岀殑榪涚▼銆?
2.1.2.3 3錛巒eed_resched
鏍囧織浣嶃傝浣嶅湪浠庝腑鏂拰緋葷粺璋冪敤涓繑鍥炵殑鏃跺欒媯鏌ワ紝need_resched涓?鐨勬椂鍊欒〃紺鴻姹傚惎鍔ㄨ皟搴︾▼搴忥紝榪欓氬父鍙戠敓鍦ㄨ繘紼嬬殑鏃墮棿鐗囧凡緇忕敤瀹岋紝鎴栬呭洜涓篒O浜嬩歡鍙戠敓鑰屽己琛屾姠鍗犲綋鍓嶈繘紼嬬殑鏃跺欍?
2.1.2.4 4錛巔olicy
榪涚▼鐨勮皟搴︾瓥鐣ャ傚鏋滆皟搴︾瓥鐣ヤ負SCHED_RR鎴栬匰CHED_FIFO鍒欒〃紺哄綋鍓嶈繘紼嬩負瀹炴椂榪涚▼錛屽惁鍒?SCHED_OTHER)涓烘櫘閫氳繘紼嬨?
2.1.3 璋冨害綆楁硶璇存槑
Linux閲囩敤鐩稿綋綆鍗曚絾瀹為檯璇佹槑鏁堟灉涓嶉敊鐨勮皟搴︾畻娉曘傚湪璋冨害鐨勬椂鍊欙紝鎵鏈夋鍦ㄨ繍琛岃繘紼嬬殑鎵ц鏉冨?goodness)閮借璁$畻錛屾渶緇堟潈鍊兼渶楂樼殑 榪涚▼鑾峰緱鎵ц鐨勬満浼氥傚亣璁懼緱鍒扮殑鏈澶ф潈鍊間負0錛屽氨璁や負鏈CPU鏃舵湡宸茬粡鎵ц瀹屾瘯錛屼細閲嶆柊璁$畻鎵鏈夎繘紼嬬殑counter鍊鹼紝寮濮嬫柊鐨凜PU鏃舵湡銆傝皟搴︾畻娉? 鐨勬牳蹇冨氨鏄痝oodness鐨勮綆楋紝璁$畻鐨勫熀鏈濊礬濡備笅錛?
濡傛灉絳夊緟璋冨害鐨勮繘紼嬫槸瀹炴椂榪涚▼錛屽畠鐨刧oodness涓?000 + 鏈韓鐨勪紭鍏堢駭,鑰屾櫘閫氳繘紼嬬殑goodness榪滃皬浜?000錛岃繖灝變繚璇佷簡瀹炴椂榪涚▼鎬繪槸浼樺厛浜庢櫘閫氳繘紼嬫墽琛屻?
濡傛灉榪涚▼鍓╀綑鐨刢ounter涓?,灝辮涓哄畠宸茬粡鐢ㄥ厜浜嗚嚜宸卞湪璇ユ椂鏈熺殑CPU鏃墮棿鐗囷紝goodness榪斿洖0銆?
瀵逛簬鍏朵粬鐨勬儏鍐碉紝鐢ㄤ笅闈㈢殑鍏紡鏉ヨ綆梘oodness:
goodness = counter + 20 – nice錛?
2.1.4 鐩稿叧鍑芥暟
1錛巗chedule() in kernel/sched.c
涓昏皟搴﹀嚱鏁幫紝閫夋嫨瑕佽繍琛岀殑榪涚▼
2錛巊oodness() in kernel/sched.c
鐢眘chedule()璋冪敤錛岃綆楄繘紼嬬殑鎵ц鏉冨?
3 璋冨害紼嬪簭鐨勬墽琛?
鍙互閫氳繃涓ょ鏂瑰紡鏉ユ縺媧昏皟搴︾▼搴忥紝鍒嗗埆鏄洿鎺ヨ皟鐢ㄥ拰寤惰繜璋冪敤銆?
3.1.1 鐩存帴璋冪敤
褰揷urrent榪涚▼鍑嗗涓誨姩鏀懼純CPU鐨勬椂鍊欙紝瀹冧細鐩存帴璋冪敤璋冨害紼嬪簭schedule()錛屽皢CPU璁╃粰鍙︿竴涓繘紼嬨?
淇冧嬌current榪涚▼涓誨姩鏀懼純CPU鐨勫師鍥犳湁涓ょ錛屼竴縐嶆儏鍐墊槸current闇瑕佺潯鐪狅紙闃誨錛夋潵絳夊緟鎵闇鐨勮祫婧愬噯澶囧ソ錛屾鏃禼urrent鐨勭姸 鎬佽璁劇疆涓篢ASK_INTERRUPTABLE鎴朤ASK_UNINTERRUPTABLE錛屽湪璋冪敤schedule()鍚庤繘紼嬭繘鍏ョ潯鐪犵姸鎬侊紱鍙︿竴縐嶆儏 鍐典笅榪涚▼璁劇疆SCHED_YIELD鐨勮皟搴︾瓥鐣ワ紝鐒跺悗璋冪敤schedule()錛屾鏃惰繘紼嬪彧鏄煭鏆傜殑鏀懼純CPU錛屽湪涓嬩竴嬈chedule()琚皟鐢ㄧ殑鏃? 鍊欒繘紼嬩細緇х畫鍙備笌CPU鐨勭珵浜夈?
3.1.2 寤惰繜璋冪敤
閫氳繃璁劇疆褰撳墠榪涚▼鐨刵eed_resched鏍囧織鏉ュ湪鍏跺悗鐨勬煇涓椂鍒繪縺媧昏皟搴︾▼搴忋傚墠闈㈣榪囷紝鍦ㄤ粠涓柇/寮傚父/緋葷粺璋冪敤涓繑鍥? 鏃訛紝need_resched鏍囧織琚鏌ワ紝鍦ㄦ爣蹇椾笉涓?鐨勬椂鍊欎細嬋媧昏皟搴︾▼搴忋備緥濡傦細褰撴椂閽熶腑鏂彂鐢熸椂錛屼腑鏂鐞嗙▼搴忔鏌ュ埌褰撳墠榪涚▼鐨勬椂闂寸墖宸茬粡鎵ц瀹? 姣曪紝瀹冨氨浼氳緗綋鍓嶈繘紼嬬殑need_resched鏍囧織錛涘彟涓涓緥瀛愭槸褰撴煇涓狪O涓柇鍙戠敓鏃訛紝涓柇澶勭悊紼嬪簭鍙戠幇鏈夎繘紼嬪湪絳夊緟璇O浜嬩歡錛屽畠浼氬皢姝e湪絳夊緟鐨? 榪涚▼鐨勭姸鎬佸彉涓烘墽琛屾侊紝騫惰緗綋鍓嶈繘紼嬬殑need_resched鏍囧織銆傚綋涓柇澶勭悊紼嬪簭涓緇撴潫錛岀郴緇熶細閲嶆柊璋冨害錛屽湪榪欑鎯呭喌涓嬶紝鏂拌漿鍏ユ墽琛屾佺殑榪涚▼寰堝彲鑳? 浼氳幏寰楁墽琛屾満浼氾紝浠庤屼嬌緋葷粺淇濇寔瀵笽O浜嬩歡鐨勫揩閫熷搷搴斻?
3.1.3 鐩稿叧鍑芥暟
1錛巜ake_up_common() in kernel/sched.c
嬋媧籌O絳夊緟闃熷垪涓殑榪涚▼錛屽畠浼氶『搴忚皟鐢╰ry_to_wake_up()錛宺eschedule_idle()絳夊嚱鏁版潵瑕佹眰瀵硅繘紼嬭繘紼嬮噸鏂拌皟搴︺?
2錛巇o_timer() in kernel/timer.c
瀹氭椂鏃墮挓涓柇紼嬪簭錛屽噺灝戝綋鍓嶈繘紼嬬殑counter鍊鹼紝濡傛灉counter宸茬粡鐢ㄥ畬錛屽垯璁劇疆榪涚▼鐨刵eed_resched鍩熻姹傞噸鏂拌皟搴︺?
3錛巖et_from_intr/sys_call/exception in arch/i386/entry.S
姹囩紪璇█涓殑紼嬪簭鐐癸紝鍦ㄤ粠涓柇/寮傚父/緋葷粺璋冪敤涓繑鍥炴椂閮戒細鎵ц榪欎竴孌電▼搴忥紝媯鏌ュ綋鍓嶈繘紼嬬殑need_resched鍩燂紝濡傛灉涓嶄負0灝變細嬋媧籹chedule()閲嶆柊璋冨害銆?


4 榪涚▼璋冨害紺烘剰鍥?
linux鐨勮繘紼嬭皟搴﹀鍥?鎵紺恒?br> 

6 闂涓庣瓟妗?
Q錛庡湪褰撳墠緋葷粺涓嬶紝璋冨害鏃墮棿鐗囩殑闀垮害鏄灝戯紵
A. 涓?.2.x鐗堢殑鍐呮牳鐩告瘮錛宬ernel2.4.x鐨勬椂闂寸墖闀垮害緙╃煭浜嗭紝瀵逛簬鏈楂樹紭鍏堢駭鐨勮繘紼嬫潵璇達紝鏃墮棿鐗囩殑闀垮害涓?00ms錛岄粯璁や紭鍏堢駭榪涚▼鐨勬椂闂寸墖闀垮害涓?0ms錛岃屾渶浣庝紭鍏堢駭榪涚▼鐨勬椂闂寸墖闀垮害涓?0ms銆?

Q. Linux濡備綍淇濊瘉瀵笽/O浜嬩歡鐩稿姣旇緝蹇殑鍝嶅簲閫熷害錛岃繖涓搷搴旈熷害鏄惁涓庤皟搴︽椂闂寸墖鐨勯暱鐭湁鍏籌紵
A錛庡綋I/O浜嬩歡鍙戠敓鐨勬槸鏃跺欙紝瀵瑰簲鐨勪腑鏂鐞嗙▼搴忚嬋媧伙紝褰撳畠鍙戠幇鏈夎繘紼嬪湪絳夊緟榪欎釜I/O浜嬩歡鐨勬椂鍊欙紝瀹冧細嬋媧葷瓑寰呰繘紼嬶紝騫朵笖璁劇疆褰撳墠姝e湪鎵ц 榪涚▼鐨刵eed_resched鏍囧織錛岃繖鏍峰湪涓柇澶勭悊紼嬪簭榪斿洖鐨勬椂鍊欙紝璋冨害紼嬪簭琚縺媧伙紝鍘熸潵鍦ㄧ瓑寰匢/O浜嬩歡鐨勮繘紼嬶紙寰堝彲鑳斤級鑾峰緱鎵ц鏉冿紝浠庤屼繚璇佷簡瀵笽 /O浜嬩歡鐨勭浉瀵瑰揩閫熷搷搴旓紙姣綰э級銆?
浠庝笂闈㈢殑璇存槑鍙互鐪嬪嚭錛屽湪I/O浜嬩歡鍙戠敓鐨勬椂鍊欙紝I/O浜嬩歡鐨勫鐞嗚繘紼嬩細鎶㈠崰褰撳墠榪涚▼錛屽搷搴旈熷害涓庤皟搴︽椂闂寸墖鐨勯暱搴︽棤鍏熾?

Q錛庨珮浼樺厛綰?nice)榪涚▼鍜屼綆浼樺厛綰ц繘紼嬪湪鎵ц涓婃湁浣曞尯鍒紵渚嬪涓涓紭鍏堢駭涓?19錛堟渶楂樹紭鍏堢駭錛夌殑榪涚▼鍜屼紭鍏堢駭涓?0錛堟渶浣庯級鐨勮繘紼嬫湁浣曞尯鍒?
A. 榪涚▼鑾峰緱鐨凜PU鏃墮棿鐨勭粷瀵規(guī)暟鐩彇鍐充簬瀹冪殑鍒濆counter鍊鹼紝鍒濆鐨刢ounter鐨勮綆楀叕寮?sched.c in kernel 2.4.14)濡備笅錛?
p->counter = (p->counter >> 1) + ((20 - p->nice) >> 2) +1)
鐢卞叕寮忓彲浠ヨ綆楀嚭錛屽浜庢爣鍑嗚繘紼嬶紙p->nice 涓?錛夛紝 寰楀埌鐨勫垵濮媍ounter涓?錛屽嵆榪涚▼鑾峰緱鐨勬椂闂寸墖涓?0ms銆?
鏈楂樹紭鍏堢駭榪涚▼錛坣ice涓?19錛夌殑鍒濆counter鍊間負10錛岃繘紼嬬殑鏃墮棿鐗囦負100ms銆?
鏈浣庝紭鍏堢駭榪涚▼錛坣ice涓?0錛夌殑鍒濆counter鍊間負1,榪涚▼鏃墮棿鐗囦負10ms銆?
緇撹鏄渶楂樹紭鍏堢駭榪涚▼浼氳幏寰楁渶浣庝紭鍏堢駭榪涚▼10鍊嶇殑鎵ц鏃墮棿錛屾櫘閫氫紭鍏堢駭榪涚▼鎺ヨ繎涓ゅ嶇殑鎵ц鏃墮棿銆傚綋鐒訛紝榪欐槸鍦ㄨ繘紼嬩笉榪涜浠諱綍IO鎿嶄綔鐨勬椂鍊欑殑鏁版嵁錛屽湪鏈塈O鎿嶄綔鐨勬椂鍊欙紝榪涚▼浼氱粡甯歌榪潯鐪犳潵絳夊緟IO鎿嶄綔鐨勫畬鎴?鐪熸鎵鍗犵敤鐨凜PU鏃墮棿鏄緢闅炬瘮杈冪殑銆?
鎴戜滑鍙互鐪嬪埌姣忔閲嶆柊璁$畻counter鐨勬椂鍊欙紝鏂扮殑counter鍊奸兘瑕佸姞涓婂畠鏈韓鍓╀綑鍊肩殑涓鍗婏紝榪欑濂栧姳鍙傜敤浜庨氳繃SCHED_YIELD 涓誨姩鏀懼純CPU鐨勮繘紼嬶紝鍙湁瀹冨湪閲嶆柊璁$畻鐨勬椂鍊檆ounter鍊兼病鏈夌敤瀹岋紝鎵浠ュ湪璁$畻鍚巆ounter鍊間細澧炲ぇ錛屼絾姘歌繙涓嶅彲鑳借秴榪?0銆?

SMP緋葷粺涓殑璋冨害

7 鍙傝冩枃鐚細
1錛?linux鍐呮牳婧愪唬鐮佺増鏈?.4.14
鍦ㄤ換浣曟椂鍊欑湡瀹炵殑浠g爜鎬繪槸鎻愪緵緇欐垜浠渶鍑嗙‘鍜岃緇嗙殑璧勬枡銆傛劅璋inus Torvalds錛孉lan Cox鍜屽叾瀹僱inux寮鍙戣呯殑杈涘嫟鍔沖姩銆?
2錛嶥ANIEL P.BOVET & MARCO CESATI
<<UNDERSTANDING THE LINUX KERNEL>> ISBN: 0-596-00002-2 O’REILLY 2001
涓瘧鐗?銆婃繁鍏ョ悊瑙inux鍐呮牳銆?闄堣帀鍚涚瓑璇?ISBN: 7-5083-0719-4 涓浗鐢?shù)鍔涘嚭鐗埥C?2001銆?
鏈功鏄笓闂ㄤ粙緇峫inux鍐呮牳緇撴瀯鐨勪功涓渶璇﹀敖鐨勪竴鏈紝瀵逛唬鐮佸垎鏋愯瑙g殑涔熸瘮杈冩繁鍏ワ紝鍩轟簬2.2鐨勫唴鏍哥増鏈?
3錛嶹.Richard Stevens
銆奤NIX鐜楂樼駭緙栫▼銆?灝ゆ檵鍏冭瘧 ISBN: 7-111-07579-X 鏈烘宸ヤ笟鍑虹増紺?2000
UNIX緙栫▼鍦g粡錛岀▼搴忓憳鎵嬪ご蹇呭鐨勪功綾嶄箣涓,瀵規(guī)墍鏈塙NIX寮鍙戜漢鍛橈紝鏃犺姘村鉤楂樹綆錛岄兘鏈夊弬鑰冧環(huán)鍊箋傜炕璇戠殑姘村噯涔熼毦寰椾竴瑙佺殑楂樻槑銆?

from:
http://www.linuxforum.net/forum/gshowflat.php?Cat=&Board=linuxK&Number=294463&page=16&view=collapsed&sb=5&o=all&fpart=



chatler 2010-02-15 15:30 鍙戣〃璇勮
]]>
linux鍧楄澶囷紝瀛楃璁懼http://m.shnenglu.com/beautykingdom/archive/2010/01/28/106630.htmlchatlerchatlerThu, 28 Jan 2010 07:00:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2010/01/28/106630.htmlhttp://m.shnenglu.com/beautykingdom/comments/106630.htmlhttp://m.shnenglu.com/beautykingdom/archive/2010/01/28/106630.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/106630.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/106630.html

瀛楃璁懼榪樻槸鍧楄澶囩殑瀹氫箟灞炰簬鎿嶄綔緋葷粺鐨勮澶囪闂眰錛屼笌瀹為檯鐗╃悊璁懼鐨勭壒鎬ф棤蹇呯劧鑱旂郴銆?/p>

璁懼璁塊棶灞備笅闈㈡槸椹卞姩紼嬪簭錛屾墍浠ュ彧瑕侀┍鍔ㄧ▼搴忔彁渚涚殑鏂瑰紡錛岄兘鍙互銆備篃灝辨槸璇撮┍鍔ㄧ▼搴忔敮鎸乻tream鏂瑰紡錛岄偅涔堝氨鍙互鐢ㄨ繖縐嶆柟寮忚闂紝椹卞姩紼嬪簭濡傛灉榪樻敮鎸乥lock鏂瑰紡錛岄偅涔堜綘鎯崇敤鍝鏂瑰紡璁塊棶閮藉彲浠ワ紝鍏稿瀷鐨勬瘮濡傜‖鐩樺紡鐨勮8璁懼錛屼袱縐嶉兘鏀寔鍧楄澶囷紙block device錛夛細鏄竴縐嶅叿鏈変竴瀹氱粨鏋勭殑闅忔満瀛樺彇璁懼錛屽榪欑璁懼鐨勮鍐欐槸鎸夊潡榪涜鐨勶紝浠栦嬌鐢ㄧ紦鍐插尯鏉ュ瓨鏀炬殏鏃剁殑鏁版嵁錛屽緟鏉′歡鎴愮啛鍚庯紝浠庣紦瀛樹竴嬈℃у啓鍏ヨ澶囨垨浠庤澶囦腑涓嬈℃ц鍑烘斁鍏ュ埌緙撳啿鍖猴紝濡傜鐩樺拰鏂囦歡緋葷粺絳?/p>

瀛楃璁懼錛圕haracter device錛夛細榪欐槸涓涓『搴忕殑鏁版嵁嫻佽澶囷紝瀵硅繖縐嶈澶囩殑璇誨啓鏄寜瀛楃榪涜鐨勶紝鑰屼笖榪欎簺瀛楃鏄繛緇湴褰㈡垚涓涓暟鎹祦銆備粬涓嶅叿澶囩紦鍐插尯錛屾墍浠ュ榪欑璁懼鐨勮鍐欐槸瀹炴椂鐨勶紝濡傜粓绔佺甯︽満絳夈?br>緋葷粺涓兘澶熼殢鏈猴紙涓嶉渶瑕佹寜欏哄簭錛夎闂浐瀹氬ぇ灝忔暟鎹墖錛坈hunks錛夌殑璁懼琚О浣滃潡璁懼錛岃繖浜涙暟鎹墖灝辯О浣滃潡銆傛渶甯歌鐨勫潡璁懼鏄‖鐩橈紝闄ゆ浠ュ錛岃繕鏈夎蔣鐩橀┍鍔ㄥ櫒銆丆D-ROM椹卞姩鍣ㄥ拰闂瓨絳夌瓑璁稿鍏朵粬鍧楄澶囥傛敞鎰忥紝瀹冧滑閮芥槸浠ュ畨瑁呮枃浠剁郴緇熺殑鏂瑰紡浣跨敤鐨勨斺旇繖涔熸槸鍧楄澶囦竴鑸殑璁塊棶鏂瑰紡銆?/p>

鍙︿竴縐嶅熀鏈殑璁懼綾誨瀷鏄瓧絎﹁澶囥傚瓧絎﹁澶囨寜鐓у瓧絎︽祦鐨勬柟寮忚鏈夊簭璁塊棶錛屽儚涓插彛鍜岄敭鐩樺氨閮藉睘浜庡瓧絎﹁澶囥傚鏋滀竴涓‖浠惰澶囨槸浠ュ瓧絎︽祦鐨勬柟寮忚璁塊棶鐨勮瘽錛岄偅灝卞簲璇ュ皢瀹冨綊浜庡瓧絎﹁澶囷紱鍙嶈繃鏉ワ紝濡傛灉涓涓澶囨槸闅忔満錛堟棤搴忕殑錛夎闂殑錛岄偅涔堝畠?yōu)灞炰簬鍧楄畱证囥?/p>

榪欎袱縐嶇被鍨嬬殑璁懼鐨勬牴鏈尯鍒湪浜庡畠浠槸鍚﹀彲浠ヨ闅忔満璁塊棶鈥斺旀崲鍙ヨ瘽璇村氨鏄紝鑳藉惁鍦ㄨ闂澶囨椂闅忔剰鍦頒粠涓涓綅緗煩杞埌鍙︿竴涓綅緗備婦涓緥瀛愶紝閿洏榪欑璁懼鎻愪緵鐨勫氨鏄竴涓暟鎹祦錛屽綋浣犳暡鍏?#8220;fox”榪欎釜瀛楃涓叉椂錛岄敭鐩橀┍鍔ㄧ▼搴忎細鎸夌収鍜岃緭鍏ュ畬鍏ㄧ浉鍚岀殑欏哄簭榪斿洖榪欎釜鐢變笁涓瓧絎︾粍鎴愮殑鏁版嵁嫻併傚鏋滆閿洏椹卞姩紼嬪簭鎵撲貢欏哄簭鏉ヨ瀛楃涓詫紝鎴栬鍙栧叾浠栧瓧絎︼紝閮芥槸娌℃湁鎰忎箟鐨勩傛墍浠ラ敭鐩樺氨鏄竴縐嶅吀鍨嬬殑瀛楃璁懼錛屽畠鎻愪緵鐨勫氨鏄敤鎴蜂粠閿洏杈撳叆鐨勫瓧絎︽祦銆傚閿洏榪涜璇繪搷浣滀細寰楀埌涓涓瓧絎︽祦錛岄鍏堟槸“f”錛岀劧鍚庢槸“o”錛屾渶鍚庢槸“x”錛屾渶緇堟槸鏂囦歡鐨勭粨鏉?EOF)銆傚綋娌′漢鏁查敭鐩樻椂錛屽瓧絎︽祦灝辨槸絀虹殑銆傜‖鐩樿澶囩殑鎯呭喌灝變笉澶т竴鏍蜂簡銆傜‖鐩樿澶囩殑椹卞姩鍙兘瑕佹眰璇誨彇紓佺洏涓婁換鎰忓潡鐨勫唴瀹癸紝鐒跺悗鍙堣漿鍘昏鍙栧埆鐨勫潡鐨勫唴瀹癸紝鑰岃璇誨彇鐨勫潡鍦ㄧ鐩樹笂浣嶇疆涓嶄竴瀹氳榪炵畫錛屾墍浠ヨ紜洏鍙互琚殢鏈鴻闂紝鑰屼笉鏄互嫻佺殑鏂瑰紡琚闂紝鏄劇劧瀹冩槸涓涓潡璁懼銆?/p>

鍐呮牳綆$悊鍧楄澶囪姣旂鐞嗗瓧絎﹁澶囩粏鑷村緱澶氾紝闇瑕佽冭檻鐨勯棶棰樺拰瀹屾垚鐨勫伐浣滅浉姣斿瓧絎﹁澶囨潵璇磋澶嶆潅璁稿銆傝繖鏄洜涓哄瓧絎﹁澶囦粎浠呴渶瑕佹帶鍒朵竴涓綅緗斿綋鍓嶄綅緗旇屽潡璁懼璁塊棶鐨勪綅緗繀欏昏兘澶熷湪浠嬭川鐨勪笉鍚屽尯闂村墠鍚庣Щ鍔ㄣ傛墍浠ヤ簨瀹炰笂鍐呮牳涓嶅繀鎻愪緵涓涓笓闂ㄧ殑瀛愮郴緇熸潵綆$悊瀛楃璁懼錛屼絾鏄鍧楄澶囩殑綆$悊鍗村繀欏昏鏈変竴涓笓闂ㄧ殑鎻愪緵鏈嶅姟鐨勫瓙緋葷粺銆備笉浠呬粎鏄洜涓哄潡璁懼鐨勫鏉傛ц繙榪滈珮浜庡瓧絎﹁澶囷紝鏇撮噸瑕佺殑鍘熷洜鏄潡璁懼瀵規(guī)墽琛屾ц兘鐨勮姹傚緢楂橈紱瀵圭‖鐩樻瘡澶氫竴鍒嗗埄鐢ㄩ兘浼氬鏁翠釜緋葷粺鐨勬ц兘甯︽潵鎻愬崌錛屽叾鏁堟灉瑕佽繙榪滄瘮閿洏鍚炲悙閫熷害鎴愬嶇殑鎻愰珮澶у緱澶氥傚彟澶栵紝鎴戜滑灝嗕細鐪嬪埌錛屽潡璁懼鐨勫鏉傛т細涓鴻繖縐嶄紭鍖栫暀涓嬪緢澶х殑鏂藉睍絀洪棿.

from:

http://os.51cto.com/art/200909/151133.htm



chatler 2010-01-28 15:00 鍙戣〃璇勮
]]>
linux鍐呮牳妯″潡綆$悊鍛戒護http://m.shnenglu.com/beautykingdom/archive/2009/12/10/102938.htmlchatlerchatlerThu, 10 Dec 2009 14:48:00 GMThttp://m.shnenglu.com/beautykingdom/archive/2009/12/10/102938.htmlhttp://m.shnenglu.com/beautykingdom/comments/102938.htmlhttp://m.shnenglu.com/beautykingdom/archive/2009/12/10/102938.html#Feedback0http://m.shnenglu.com/beautykingdom/comments/commentRss/102938.htmlhttp://m.shnenglu.com/beautykingdom/services/trackbacks/102938.html

chatler 2009-12-10 22:48 鍙戣〃璇勮
]]>
Linux "闆舵嫹璐? sendfile鍑芥暟涓枃璇存槑鍙婂疄闄呮搷浣滃垎鏋?/title><link>http://m.shnenglu.com/beautykingdom/archive/2009/11/28/102185.html</link><dc:creator>chatler</dc:creator><author>chatler</author><pubDate>Sat, 28 Nov 2009 12:08:00 GMT</pubDate><guid>http://m.shnenglu.com/beautykingdom/archive/2009/11/28/102185.html</guid><wfw:comment>http://m.shnenglu.com/beautykingdom/comments/102185.html</wfw:comment><comments>http://m.shnenglu.com/beautykingdom/archive/2009/11/28/102185.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/beautykingdom/comments/commentRss/102185.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/beautykingdom/services/trackbacks/102185.html</trackback:ping><description><![CDATA[  Sendfile鍑芥暟璇存槑 <div> </div> <div>#include <sys/sendfile.h></div> <div>ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count);</div> <div> </div> <div>sendfile()鏄綔鐢ㄤ簬鏁版嵁鎷瘋礉鍦ㄤ袱涓枃浠舵弿榪扮涔嬮棿鐨勬搷浣滃嚱鏁?榪欎釜鎷瘋礉鎿嶄綔鏄唴鏍鎬腑鎿嶄綔鐨?鎵浠ョО涓?闆舵嫹璐?.sendfile鍑芥暟姣旇搗read鍜寃rite鍑芥暟楂樻晥寰楀,鍥犱負read鍜寃rite鏄鎶婃暟鎹嫹璐濆埌鐢ㄦ埛搴旂敤灞傛搷浣?</div> <div> </div> <div>鍙傛暟璇存槑:</div> <div>out_fd 鏄凡緇忔墦寮浜?鐢ㄤ簬鍐欐搷浣?write)鐨勬枃浠舵弿榪扮;</div> <div>in_fd 鏄凡緇忔墦寮浜?鐢ㄤ簬璇繪搷浣?read)鐨勬枃浠舵弿榪扮;</div> <div>offset 鍋忕Щ閲?琛ㄧずsendfile鍑芥暟浠巌n_fd涓殑鍝竴鍋忕Щ閲忓紑濮嬭鍙栨暟鎹?濡傛灉鏄浂琛ㄧず浠庢枃浠剁殑寮濮嬭,鍚﹀垯浠庣浉搴旂殑渚垮疁閲忚鍙?濡傛灉鏄驚鐜鍙栫殑鏃跺?涓嬩竴嬈ffset鍊煎簲涓簊endfile鍑芥暟榪斿洖鍊煎姞涓婃湰嬈$殑offset鐨勫?</div> <div>count鏄湪涓や釜鎻忚堪絎︿箣闂存嫹璐濈殑瀛楄妭鏁?bytes)</div> <div> </div> <div>榪斿洖鍊?</div> <div>濡傛灉鎴愬姛鐨勬嫹璐?榪斿洖鍐欐搷浣滃埌out_fd鐨勫瓧鑺傛暟,閿欒榪斿洖-1,騫剁浉搴旂殑璁劇疆error淇℃伅.</div> <div> </div> <div>EAGAIN 鏃犻樆濉濱/O璁劇疆O_NONBLOCK鏃?鍐欐搷浣?write)闃誨浜?</div> <div>EBADF 杈撳嚭鎴栬呰緭鍏ョ殑鏂囦歡鎻忚堪絎︽病鏈夋墦寮.</div> <div>EFAULT 閿欒鐨勫湴鍧.</div> <div>EINVAL 鎻忚堪絎︿笉鍙敤鎴栬呴攣瀹氫簡,鎴栬呯敤mmap()鍑芥暟鎿嶄綔鐨刬n_fd涓嶅彲鐢?</div> <div>EIO 褰撹鍙?read)in_fd鏃跺彂鐢熸湭鐭ラ敊璇?</div> <div>ENOMEM 璇?read)in_fd鏃跺唴瀛樹笉瓚?</div> <div> </div> <div>------------------------------------------------------------------------------</div> <div> </div> <div> <div>鐢變簬鎯沖啀鎻愬崌鍘熸湁緋葷粺涓枃浠朵紶杈撴ā鍧楃殑閫熷害,騫跺噺灝戠郴緇熻祫婧愬崰鐢?榪涜浜嗕竴嬈endfile()鐨勬ц兘嫻嬭瘯,浣嗗け璐ヤ簡.涓嶈繃榪樻槸灝嗗畠鐢ㄥ湪浜嗘ā鍧椾腑.璁板綍涓涓嬭繖嬈″け鏀圭殑寰皟嫻嬭瘯.</div> <div> </div> <div>榪愯騫沖彴: 瀹㈡埛鏈轟笌鏈嶅姟鍣ㄥ潎涓篜4璁$畻鏈?IDE紜洏; Fedora5鍙戣鐗? 鐧懼厗灞鍩熺綉;</div> <div> </div> <div>鎺ユ敹绔▼搴忓涓?</div> <div> <table style="font-size: 12px; width: 88.05%; height: 123px; " align="center"> <tbody> <tr> <td> <p>  FILE *fp = fopen(FILENAME,"wb");</p> <p>  while((len = recv(sockfd, buff, sizeof(buff), 0)) > 0)<br>  {<br>      fwrite(buffer, 1, len, fp);<br>  }<br>  fclose(fp);</p> </td> </tr> </tbody> </table> </div> <div> </div> <div> </div> <div>A. 鍙戦佺浼犵粺鏂瑰紡浠g爜孌靛涓?</div> <div> <table style="font-size: 12px; width: 88.67%; height: 139px; " align="center"> <tbody> <tr> <td>  fd = open(FILENAME, O_RDONLY);<br>  while((len =read(fd, buff, sizeof(buff))) >0) <br>  {<br>       send(sockfd, buff, len ,0);<br>  }<br>  close(fd);  </td> </tr> </tbody> </table> </div> <p>鐢變簬鎴戠鐩樺垎鍖烘椂鎸囧畾鐨勫潡澶у皬涓?096,涓轟簡鏈浼樿鍙栫鐩樻暟鎹?buff澶у皬璁句負4096瀛楄妭.浣嗗湪嫻嬭瘯涓彂鐜拌涓?024鎴?192涓嶄細瀵逛紶杈撻熷害甯︽潵褰卞搷.</p> <p>鏂囦歡澶у皬:9M; 鑰楁椂:0.71 - 0.76縐?<br>鏂囦歡澶у皬:32M; 鑰楁椂:2.64 - 2.68縐?<br>鏂囦歡澶у皬:64M; 鑰楁椂:5.36 - 5.43縐?</p> <p>B. 浣跨敤sendfile()浼犺緭浠g爜孌?<br> <table style="font-size: 12px; width: 86.6%; height: 143px; " align="center"> <tbody> <tr> <td> <p>  off_t offset = 0;<br>  stat(FILENAME, &filestat);</p> <p>  fd = open(FILENAME, O_RDONLY);<br>  sendfile(sockfd, fd, &offset, filestat.st_size) );<br>  close(fd);  </p> </td> </tr> </tbody> </table> </p> <p>鏂囦歡澶у皬:9M; 鑰楁椂:0.71 - 1.08縐?<br>鏂囦歡澶у皬:32M; 鑰楁椂:2.66 - 2.74縐?<br>鏂囦歡澶у皬:64M; 鑰楁椂:5.43 - 6.64縐?</p> <p>浼間箮榪樼暐鏈変笅闄?鏍規(guī)嵁sendfile鐨刴an鎵嬪唽,鎴戝湪浣跨敤璇ュ嚱鏁板墠璋冪敤浜?br> <table style="font-size: 12px; width: 87.43%; height: 75px; " align="center"> <tbody> <tr> <td> <p> int no = 1;<br> printf("%d\n", setsockopt(sockfd, IPPROTO_TCP, TCP_CORK, (char*)&no, sizeof(int)) );</p> </td> </tr> </tbody> </table> </p> <p>鏂囦歡澶у皬:9M; 鑰楁椂:0.72 - 0.75縐?<br>鏂囦歡澶у皬:32M; 鑰楁椂:2.66 - 2.68縐?<br>鏂囦歡澶у皬:64M; 鑰楁椂:5.38 - 5.60縐?</p> <p>榪欐牱浼間箮杈懼埌浜嗕紶緇熸柟寮忕殑閫熷害?!涓嶇鍝鐜涓?鎴戠敤ethereal鎶撳寘鏄劇ず姣忎竴涓猼cp鍖呯殑playload閮ㄥ垎鏈澶т篃閫氬父鏄?448瀛楄妭.</p> <p>鐪嬫潵鎴戠殑嫻嬭瘯娌℃湁浣撶幇鍑?搴旂敤灞傛暟鎹殑涓ゆ鎷瘋礉甯︽潵寰堝ぇ鐨勬秷鑰?榪欎竴璇存硶.濡傛灉鎸夌収瀛樺湪灝辨槸鏈夌悊鐨勮娉曠殑璇?閭f垜鎯硈endfile()鍦ㄤ袱縐嶆儏鍐典笅鎵嶄綋鐜頒紭鍔?浣嗘垜鍗存病鏈夌幆澧冩祴璇?<br>1. 澶у茍鍙戦噺鐨勬枃浠舵湇鍔″櫒鎴朒TTP鏈嶅姟鍣?<br>2. 鍐呭瓨璧勬簮绱у紶鐨勫祵鍏ュ紡緋葷粺;</p> <p>鍙﹀,緗戠粶涓婂ぇ閲忕殑鍏充簬tcp閫夐」涓殑TCP_CORK鎻忚堪宸茬粡榪囨椂.鍦╩an鎵嬪唽涓棭宸叉彁鍒拌鍙傛暟鍙互涓嶵CP_NODELAY緇撳悎浣跨敤浜?鍙槸,鍙璁劇疆浜員CP_NODELAY閫夐」鍚?涓嶇鏄惁璁劇疆TCP_CORK,鍖呴兘浼氱珛鍗沖彂鍑?</p> <p>----------------------------------------------------------------------</p> <p>琛ュ厖:</p> <p>TCP_NODELAY鍜孴CP_CORK鍩烘湰涓婃帶鍒朵簡鍖呯殑“Nagle鍖?#8221;錛孨agle鍖栧湪榪欓噷鐨勫惈涔夋槸閲囩敤Nagle綆楁硶鎶婅緝?yōu)畯鐨勫寘缁勮湄撴洿澶х殑鍝徙?John Nagle鏄疦agle綆楁硶鐨勫彂鏄庝漢錛屽悗鑰呭氨鏄敤浠栫殑鍚嶅瓧鏉ュ懡鍚嶇殑錛屼粬鍦?984騫撮嬈$敤榪欑鏂規(guī)硶鏉ュ皾璇曡В鍐崇鐗規(guī)苯杞﹀叕鍙哥殑緗戠粶鎷ュ闂錛堟浜嗚В璇︽儏璇峰弬鐪婭ETF RFC 896錛夈備粬瑙e喅鐨勯棶棰樺氨鏄墍璋撶殑silly window syndrome 錛屼腑鏂囩О“鎰氳牏紿楀彛鐥囧欑兢”錛屽叿浣撳惈涔夋槸錛屽洜涓烘櫘閬嶇粓绔簲鐢ㄧ▼搴忔瘡浜х敓涓嬈″嚮閿搷浣滃氨浼氬彂閫佷竴涓寘錛岃屽吀鍨嬫儏鍐典笅涓涓寘浼氭嫢鏈変竴涓瓧鑺傜殑鏁版嵁杞借嵎浠ュ強40涓瓧鑺傞暱鐨勫寘澶達紝浜庢槸浜х敓4000%鐨勮繃杞斤紝寰堣交鏄撳湴灝辮兘浠ょ綉緇滃彂鐢熸嫢濉?銆?Nagle鍖栧悗鏉ユ垚浜嗕竴縐嶆爣鍑嗗茍涓旂珛鍗沖湪鍥犵壒緗戜笂寰椾互瀹炵幇銆傚畠鐜板湪宸茬粡鎴愪負緙虹渷閰嶇疆浜嗭紝浣嗗湪鎴戜滑鐪嬫潵錛屾湁浜涘満鍚堜笅鎶婅繖涓閫夐」鍏蟲帀涔熸槸鍚堜箮闇瑕佺殑銆?</p> <p>鐜板湪璁╂垜浠亣璁炬煇涓簲鐢ㄧ▼搴忓彂鍑轟簡涓涓姹傦紝甯屾湜鍙戦佸皬鍧楁暟鎹傛垜浠彲浠ラ夋嫨绔嬪嵆鍙戦佹暟鎹垨鑰呯瓑寰呬駭鐢熸洿澶氱殑鏁版嵁鐒跺悗鍐嶄竴嬈″彂閫佷袱縐嶇瓥鐣ャ傚鏋滄垜浠┈涓婂彂閫佹暟鎹紝閭d箞浜や簰鎬х殑浠ュ強瀹㈡埛/鏈嶅姟鍣ㄥ瀷鐨勫簲鐢ㄧ▼搴忓皢鏋佸ぇ鍦板彈鐩娿備緥濡傦紝褰撴垜浠鍦ㄥ彂閫佷竴涓緝鐭殑璇鋒眰騫朵笖絳夊欒緝澶х殑鍝嶅簲鏃訛紝鐩稿叧榪囪澆涓庝紶杈撶殑鏁版嵁鎬婚噺鐩告瘮灝變細姣旇緝浣庯紝鑰屼笖錛屽鏋滆姹傜珛鍗沖彂鍑洪偅涔堝搷搴旀椂闂翠篃浼氬揩涓浜涖備互涓婃搷浣滃彲浠ラ氳繃璁劇疆濂楁帴瀛楃殑TCP_NODELAY閫夐」鏉ュ畬鎴愶紝榪欐牱灝辯鐢ㄤ簡 Nagle綆楁硶銆?</p> <p>鍙﹀涓縐嶆儏鍐靛垯闇瑕佹垜浠瓑鍒版暟鎹噺杈懼埌鏈澶ф椂鎵嶉氳繃緗戠粶涓嬈″彂閫佸叏閮ㄦ暟鎹紝榪欑鏁版嵁浼犺緭鏂瑰紡鏈夌泭浜庡ぇ閲忔暟鎹殑閫氫俊鎬ц兘錛屽吀鍨嬬殑搴旂敤灝辨槸鏂囦歡鏈嶅姟鍣ㄣ傚簲鐢∟agle綆楁硶鍦ㄨ繖縐嶆儏鍐典笅灝變細浜х敓闂銆備絾鏄紝濡傛灉浣犳鍦ㄥ彂閫佸ぇ閲忔暟鎹紝浣犲彲浠ヨ緗甌CP_CORK閫夐」紱佺敤Nagle鍖栵紝鍏舵柟寮忔濂藉悓 TCP_NODELAY鐩稿弽錛圱CP_CORK 鍜?TCP_NODELAY 鏄簰鐩告帓鏂ョ殑錛夈備笅闈㈠氨璁╂垜浠粩緇嗗垎鏋愪笅鍏跺伐浣滃師鐞嗐?</p> <p>鍋囪搴旂敤紼嬪簭浣跨敤sendfile()鍑芥暟鏉ヨ漿縐誨ぇ閲忔暟鎹傚簲鐢ㄥ崗璁氬父瑕佹眰鍙戦佹煇浜涗俊鎭潵棰勫厛瑙i噴鏁版嵁錛岃繖浜涗俊鎭叾瀹炲氨鏄姤澶村唴瀹廣傚吀鍨嬫儏鍐典笅鎶ュご寰堝皬錛岃屼笖濂楁帴瀛椾笂璁劇疆浜員CP_NODELAY銆傛湁鎶ュご鐨勫寘灝嗚绔嬪嵆浼犺緭錛屽湪鏌愪簺鎯呭喌涓嬶紙鍙栧喅浜庡唴閮ㄧ殑鍖呰鏁板櫒錛夛紝鍥犱負榪欎釜鍖呮垚鍔熷湴琚鏂規(guī)敹鍒板悗闇瑕佽姹傚鏂圭‘璁ゃ傝繖鏍鳳紝澶ч噺鏁版嵁鐨勪紶杈撳氨浼氳鎺ㄨ繜鑰屼笖浜х敓浜嗕笉蹇呰鐨勭綉緇滄祦閲忎氦鎹€?</p> <p>浣嗘槸錛屽鏋滄垜浠湪濂楁帴瀛椾笂璁劇疆浜員CP_CORK錛堝彲浠ユ瘮鍠諱負鍦ㄧ閬撲笂鎻掑叆“濉炲瓙”錛夐夐」錛屽叿鏈夋姤澶寸殑鍖呭氨浼氬~琛ュぇ閲忕殑鏁版嵁錛屾墍鏈夌殑鏁版嵁閮芥牴鎹ぇ灝忚嚜鍔ㄥ湴閫氳繃鍖呬紶杈撳嚭鍘匯傚綋鏁版嵁浼犺緭瀹屾垚鏃訛紝鏈濂藉彇娑圱CP_CORK 閫夐」璁劇疆緇欒繛鎺?#8220;鎷斿幓濉炲瓙”浠ヤ究浠諱竴閮ㄥ垎鐨勫撫閮借兘鍙戦佸嚭鍘匯傝繖鍚?#8220;濉炰綇”緗戠粶榪炴帴鍚岀瓑閲嶈銆?</p> <p>鎬昏岃█涔嬶紝濡傛灉浣犺偗瀹氳兘涓璧峰彂閫佸涓暟鎹泦鍚堬紙渚嬪HTTP鍝嶅簲鐨勫ご鍜屾鏂囷級錛岄偅涔堟垜浠緩璁綘璁劇疆TCP_CORK閫夐」錛岃繖鏍峰湪榪欎簺鏁版嵁涔嬮棿涓嶅瓨鍦ㄥ歡榪熴傝兘鏋佸ぇ鍦版湁鐩婁簬WWW銆丗TP浠ュ強鏂囦歡鏈嶅姟鍣ㄧ殑鎬ц兘錛屽悓鏃朵篃綆鍖栦簡浣犵殑宸ヤ綔銆?<br>杞嚜錛?br><a >http://blog.chinaunix.net/u2/76292/showart.php?id=2105375</a><br></p> </div><img src ="http://m.shnenglu.com/beautykingdom/aggbug/102185.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/beautykingdom/" target="_blank">chatler</a> 2009-11-28 20:08 <a href="http://m.shnenglu.com/beautykingdom/archive/2009/11/28/102185.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <a href="http://m.shnenglu.com/">青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品</a> <div style="position:fixed;left:-9000px;top:-9000px;"><font id="pjuwb"></font><button id="pjuwb"><pre id="pjuwb"></pre></button><sub id="pjuwb"></sub><tbody id="pjuwb"><var id="pjuwb"><address id="pjuwb"></address></var></tbody><listing id="pjuwb"><label id="pjuwb"><strong id="pjuwb"></strong></label></listing><wbr id="pjuwb"><small id="pjuwb"><tbody id="pjuwb"></tbody></small></wbr><ins id="pjuwb"><xmp id="pjuwb"></xmp></ins><style id="pjuwb"></style><label id="pjuwb"><em id="pjuwb"><li id="pjuwb"></li></em></label><samp id="pjuwb"></samp><menu id="pjuwb"><input id="pjuwb"></input></menu><pre id="pjuwb"><tbody id="pjuwb"><tfoot id="pjuwb"><button id="pjuwb"></button></tfoot></tbody></pre><form id="pjuwb"></form><i id="pjuwb"><style id="pjuwb"><label id="pjuwb"><sup id="pjuwb"></sup></label></style></i><li id="pjuwb"><table id="pjuwb"><abbr id="pjuwb"></abbr></table></li><video id="pjuwb"></video><dfn id="pjuwb"></dfn><progress id="pjuwb"></progress><strong id="pjuwb"></strong><mark id="pjuwb"></mark><em id="pjuwb"></em><tbody id="pjuwb"><p id="pjuwb"><strike id="pjuwb"><acronym id="pjuwb"></acronym></strike></p></tbody><option id="pjuwb"></option><strike id="pjuwb"></strike><u id="pjuwb"></u><td id="pjuwb"><center id="pjuwb"><tr id="pjuwb"></tr></center></td><em id="pjuwb"><mark id="pjuwb"><em id="pjuwb"><tt id="pjuwb"></tt></em></mark></em><strong id="pjuwb"></strong><wbr id="pjuwb"></wbr><s id="pjuwb"></s><strong id="pjuwb"></strong><legend id="pjuwb"></legend><nav id="pjuwb"></nav><dl id="pjuwb"><th id="pjuwb"><dl id="pjuwb"></dl></th></dl><noframes id="pjuwb"><ins id="pjuwb"></ins></noframes><font id="pjuwb"></font><strike id="pjuwb"><i id="pjuwb"><style id="pjuwb"><label id="pjuwb"></label></style></i></strike><output id="pjuwb"></output><thead id="pjuwb"><pre id="pjuwb"></pre></thead><source id="pjuwb"></source><menuitem id="pjuwb"><wbr id="pjuwb"></wbr></menuitem><pre id="pjuwb"><span id="pjuwb"><pre id="pjuwb"><big id="pjuwb"></big></pre></span></pre><cite id="pjuwb"><fieldset id="pjuwb"><s id="pjuwb"><rt id="pjuwb"></rt></s></fieldset></cite><big id="pjuwb"><progress id="pjuwb"><big id="pjuwb"></big></progress></big><samp id="pjuwb"><delect id="pjuwb"></delect></samp><dl id="pjuwb"></dl><strike id="pjuwb"><nav id="pjuwb"><dl id="pjuwb"><strong id="pjuwb"></strong></dl></nav></strike><tbody id="pjuwb"><b id="pjuwb"><optgroup id="pjuwb"><rp id="pjuwb"></rp></optgroup></b></tbody><em id="pjuwb"></em><xmp id="pjuwb"><blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote></xmp> <i id="pjuwb"><abbr id="pjuwb"><i id="pjuwb"><abbr id="pjuwb"></abbr></i></abbr></i><center id="pjuwb"><acronym id="pjuwb"><center id="pjuwb"></center></acronym></center><pre id="pjuwb"></pre><ul id="pjuwb"><thead id="pjuwb"></thead></ul><blockquote id="pjuwb"><pre id="pjuwb"><sup id="pjuwb"></sup></pre></blockquote><acronym id="pjuwb"></acronym><big id="pjuwb"><s id="pjuwb"></s></big><th id="pjuwb"></th><th id="pjuwb"></th><tbody id="pjuwb"></tbody><thead id="pjuwb"><strike id="pjuwb"></strike></thead><th id="pjuwb"><dl id="pjuwb"><wbr id="pjuwb"></wbr></dl></th><dl id="pjuwb"><strong id="pjuwb"></strong></dl><abbr id="pjuwb"><noframes id="pjuwb"><noscript id="pjuwb"></noscript></noframes></abbr><td id="pjuwb"><ol id="pjuwb"></ol></td><li id="pjuwb"><noscript id="pjuwb"><abbr id="pjuwb"></abbr></noscript></li><small id="pjuwb"><bdo id="pjuwb"><nav id="pjuwb"></nav></bdo></small><style id="pjuwb"></style><optgroup id="pjuwb"><table id="pjuwb"></table></optgroup><center id="pjuwb"><tr id="pjuwb"><dfn id="pjuwb"></dfn></tr></center><th id="pjuwb"></th><u id="pjuwb"></u><tfoot id="pjuwb"><legend id="pjuwb"><i id="pjuwb"></i></legend></tfoot><mark id="pjuwb"></mark><meter id="pjuwb"></meter><nav id="pjuwb"></nav><acronym id="pjuwb"><pre id="pjuwb"><acronym id="pjuwb"><ul id="pjuwb"></ul></acronym></pre></acronym><acronym id="pjuwb"><pre id="pjuwb"><acronym id="pjuwb"><ul id="pjuwb"></ul></acronym></pre></acronym><nobr id="pjuwb"></nobr><sub id="pjuwb"><th id="pjuwb"><menuitem id="pjuwb"><wbr id="pjuwb"></wbr></menuitem></th></sub><thead id="pjuwb"><sub id="pjuwb"></sub></thead><ul id="pjuwb"><address id="pjuwb"><menuitem id="pjuwb"><meter id="pjuwb"></meter></menuitem></address></ul><dfn id="pjuwb"></dfn><pre id="pjuwb"></pre><input id="pjuwb"><cite id="pjuwb"><fieldset id="pjuwb"></fieldset></cite></input><u id="pjuwb"><form id="pjuwb"><u id="pjuwb"></u></form></u><kbd id="pjuwb"><em id="pjuwb"><mark id="pjuwb"></mark></em></kbd><tr id="pjuwb"></tr><del id="pjuwb"><form id="pjuwb"><address id="pjuwb"></address></form></del><tfoot id="pjuwb"><legend id="pjuwb"><ol id="pjuwb"><dl id="pjuwb"></dl></ol></legend></tfoot><menu id="pjuwb"><nobr id="pjuwb"><th id="pjuwb"><nobr id="pjuwb"></nobr></th></nobr></menu><fieldset id="pjuwb"></fieldset><pre id="pjuwb"><blockquote id="pjuwb"><samp id="pjuwb"></samp></blockquote></pre><xmp id="pjuwb"><sup id="pjuwb"><pre id="pjuwb"></pre></sup></xmp><span id="pjuwb"><progress id="pjuwb"></progress></span><font id="pjuwb"></font><var id="pjuwb"><abbr id="pjuwb"></abbr></var><strong id="pjuwb"><label id="pjuwb"><i id="pjuwb"><legend id="pjuwb"></legend></i></label></strong><tr id="pjuwb"><em id="pjuwb"><em id="pjuwb"><output id="pjuwb"></output></em></em></tr><thead id="pjuwb"><strike id="pjuwb"></strike></thead> <acronym id="pjuwb"></acronym><i id="pjuwb"></i><tt id="pjuwb"></tt><rt id="pjuwb"><source id="pjuwb"><rt id="pjuwb"></rt></source></rt><strike id="pjuwb"><acronym id="pjuwb"></acronym></strike><del id="pjuwb"></del><font id="pjuwb"><output id="pjuwb"><ins id="pjuwb"><output id="pjuwb"></output></ins></output></font><kbd id="pjuwb"><tr id="pjuwb"><kbd id="pjuwb"></kbd></tr></kbd><pre id="pjuwb"><sup id="pjuwb"><delect id="pjuwb"><samp id="pjuwb"></samp></delect></sup></pre><samp id="pjuwb"></samp><track id="pjuwb"></track><tr id="pjuwb"></tr><center id="pjuwb"></center><fieldset id="pjuwb"></fieldset><i id="pjuwb"></i><td id="pjuwb"></td><rt id="pjuwb"></rt><object id="pjuwb"></object><pre id="pjuwb"><progress id="pjuwb"><sub id="pjuwb"><thead id="pjuwb"></thead></sub></progress></pre><kbd id="pjuwb"><tr id="pjuwb"><option id="pjuwb"></option></tr></kbd><output id="pjuwb"><ins id="pjuwb"></ins></output><ol id="pjuwb"></ol><source id="pjuwb"></source><strong id="pjuwb"></strong><ruby id="pjuwb"></ruby><sub id="pjuwb"><meter id="pjuwb"><menuitem id="pjuwb"><meter id="pjuwb"></meter></menuitem></meter></sub><pre id="pjuwb"></pre><center id="pjuwb"></center><tr id="pjuwb"><tbody id="pjuwb"><xmp id="pjuwb"><dd id="pjuwb"></dd></xmp></tbody></tr><video id="pjuwb"></video><pre id="pjuwb"></pre><form id="pjuwb"><optgroup id="pjuwb"></optgroup></form><samp id="pjuwb"></samp><kbd id="pjuwb"></kbd><strong id="pjuwb"><option id="pjuwb"></option></strong><object id="pjuwb"></object><abbr id="pjuwb"><noframes id="pjuwb"><abbr id="pjuwb"></abbr></noframes></abbr><ul id="pjuwb"><del id="pjuwb"><button id="pjuwb"><pre id="pjuwb"></pre></button></del></ul><abbr id="pjuwb"></abbr><strong id="pjuwb"><code id="pjuwb"><strong id="pjuwb"></strong></code></strong><option id="pjuwb"></option><optgroup id="pjuwb"><bdo id="pjuwb"><code id="pjuwb"></code></bdo></optgroup><mark id="pjuwb"><em id="pjuwb"><font id="pjuwb"></font></em></mark><acronym id="pjuwb"><code id="pjuwb"></code></acronym><dl id="pjuwb"></dl><em id="pjuwb"></em><object id="pjuwb"><input id="pjuwb"><object id="pjuwb"></object></input></object><output id="pjuwb"><dd id="pjuwb"></dd></output><option id="pjuwb"><button id="pjuwb"><option id="pjuwb"></option></button></option><small id="pjuwb"></small></div> <a href="http://thisisfil.com" target="_blank">亚洲国产精彩中文乱码av在线播放</a>| <a href="http://gaobb52.com" target="_blank">毛片av中文字幕一区二区</a>| <a href="http://44779c.com" target="_blank">一区二区三区欧美在线</a>| <a href="http://080177.com" target="_blank">亚洲国产一区视频</a>| <a href="http://zxxx3.com" target="_blank">国内精品久久久</a>| <a href="http://chinasck.com" target="_blank">欧美二区不卡</a>| <a href="http://94wr.com" target="_blank">久久精品国产第一区二区三区</a>| <a href="http://51-express.com" target="_blank">亚洲一区成人</a>| <a href="http://xigou666.com" target="_blank">欧美一区二区三区在线看</a>| <a href="http://avse69.com" target="_blank">性色av一区二区三区红粉影视</a>| <a href="http://http456446.com" target="_blank">午夜精品久久一牛影视</a>| <a href="http://by2866.com" target="_blank">久久福利毛片</a>| <a href="http://www333393.com" target="_blank">你懂的视频欧美</a>| <a href="http://7357538.com" target="_blank">亚洲免费观看</a>| <a href="http://674446.com" target="_blank">午夜在线精品偷拍</a>| <a href="http://69ru.com" target="_blank">免费成人性网站</a>| <a href="http://137177.com" target="_blank">欧美亚洲不卡</a>| <a href="http://ahhccz.com" target="_blank">欲色影视综合吧</a>| <a href="http://kakatok.com" target="_blank">亚洲一区二区三区免费视频</a>| <a href="http://556995.com" target="_blank">久久国产婷婷国产香蕉</a>| <a href="http://3dmh145.com" target="_blank">欧美国产亚洲精品久久久8v</a>| <a href="http://ztsctgs.com" target="_blank">99日韩精品</a>| <a href="http://gzzhuangshi.com" target="_blank">久久久久久久精</a>| <a href="http://www-11688.com" target="_blank">欧美视频在线观看免费</a>| <a href="http://678665.com" target="_blank">激情综合五月天</a>| <a href="http://phitris.com" target="_blank">亚洲一区观看</a>| <a href="http://www18818.com" target="_blank">欧美激情网友自拍</a>| <a href="http://yzsss.com" target="_blank">亚洲欧美日韩综合国产aⅴ</a>| <a href="http://llamkos.com" target="_blank">免费亚洲网站</a>| <a href="http://maiiyou.com" target="_blank">国产一区二区观看</a>| <a href="http://9486322.com" target="_blank">aⅴ色国产欧美</a>| <a href="http://lukushe.com" target="_blank">久久久久久久一区二区</a>| <a href="http://3wbb.com" target="_blank">99国产麻豆精品</a>| <a href="http://www44448.com" target="_blank">久久久精品国产99久久精品芒果</a>| <a href="http://www-55125.com" target="_blank">欧美国产亚洲精品久久久8v</a>| <a href="http://bjayj.com" target="_blank">国产网站欧美日韩免费精品在线观看 </a>| <a href="http://sdxinqi.com" target="_blank">欧美一区二区视频在线</a>| <a href="http://www-777324.com" target="_blank">欧美a级理论片</a>| <a href="http://021jjjflaw.com" target="_blank">亚洲一区久久久</a>| <a href="http://cczm4.com" target="_blank">欧美精品一区在线观看</a>| <a href="http://62san.com" target="_blank">尤物视频一区二区</a>| <a href="http://77427xyz.com" target="_blank">欧美一级精品大片</a>| <a href="http://833077.com" target="_blank">日韩一级在线观看</a>| <a href="http://899gh.com" target="_blank">欧美国产亚洲另类动漫</a>| <a href="http://julong-ads.com" target="_blank">红杏aⅴ成人免费视频</a>| <a href="http://haochen072.com" target="_blank">午夜精品短视频</a>| <a href="http://sdsankeguo.com" target="_blank">亚洲肉体裸体xxxx137</a>| <a href="http://czsanlin.com" target="_blank">性欧美18~19sex高清播放</a>| <a href="http://jiarenlady.com" target="_blank">欧美日韩国产三区</a>| <a href="http://lgaoxiao.com" target="_blank">亚洲三级性片</a>| <a href="http://91sp136.com" target="_blank">亚洲第一页在线</a>| <a href="http://www311pi.com" target="_blank">亚洲小说欧美另类社区</a>| <a href="http://899399com.com" target="_blank">欧美丰满少妇xxxbbb</a>| <a href="http://9993334.com" target="_blank">亚洲电影在线看</a>| <a href="http://91chaopron.com" target="_blank">久久久久久久网</a>| <a href="http://www47755.com" target="_blank">亚洲在线观看视频网站</a>| <a href="http://739191g.com" target="_blank">亚洲国产经典视频</a>| <a href="http://tao62bao.com" target="_blank">欧美成人69av</a>| <a href="http://shalxee.com" target="_blank">亚洲国产精品一区在线观看不卡</a>| <a href="http://1235656.com" target="_blank">久久精品视频在线观看</a>| <a href="http://erzhuzi.com" target="_blank">亚洲欧美三级在线</a>| <a href="http://yx3369.com" target="_blank">国产主播在线一区</a>| <a href="http://626tw.com" target="_blank">狂野欧美激情性xxxx</a>| <a href="http://www57669.com" target="_blank">久久久99精品免费观看不卡</a>| <a href="http://yeyelu888.com" target="_blank">狠狠久久亚洲欧美专区</a>| <a href="http://kxm6868.com" target="_blank">麻豆精品视频在线观看</a>| <a href="http://whaylan.com" target="_blank">久久午夜国产精品</a>| <a href="http://13751144594.com" target="_blank">亚洲高清在线视频</a>| <a href="http://227002.com" target="_blank">欧美激情第1页</a>| <a href="http://www033459.com" target="_blank">欧美高清在线观看</a>| <a href="http://irongxun.com" target="_blank">亚洲毛片播放</a>| <a href="http://yujiaosanye.com" target="_blank">亚洲精品一区在线</a>| <a href="http://278538.com" target="_blank">国产精品第一页第二页第三页</a>| <a href="http://fxsdcj.com" target="_blank">午夜国产欧美理论在线播放 </a>| <a href="http://yw-95588.com" target="_blank">99re66热这里只有精品3直播 </a>| <a href="http://91mase.com" target="_blank">欧美一区二区视频免费观看</a>| <a href="http://www11111111.com" target="_blank">国产精品私拍pans大尺度在线</a>| <a href="http://www-833898.com" target="_blank">亚洲欧美一级二级三级</a>| <a href="http://o74sokyoss.com" target="_blank">亚洲影院免费观看</a>| <a href="http://388268.com" target="_blank">国产一区高清视频</a>| <a href="http://8484vivo.com" target="_blank">欧美福利一区</a>| <a href="http://www47777.com" target="_blank">国产精品xnxxcom</a>| <a href="http://sdtricoop.com" target="_blank">久久精品盗摄</a>| <a href="http://wwwnnnn.com" target="_blank">久久综合给合</a>| <a href="http://18mmcg.com" target="_blank">亚洲性夜色噜噜噜7777</a>| <a href="http://11b29.com" target="_blank">性做久久久久久</a>| <a href="http://77017w.com" target="_blank">亚洲人体1000</a>| <a href="http://anxingou365.com" target="_blank">亚洲一区三区视频在线观看</a>| <a href="http://80hogo.com" target="_blank">狠狠色丁香婷婷综合</a>| <a href="http://www18889.com" target="_blank">亚洲国产精品久久</a>| <a href="http://wwwbbb888999.com" target="_blank">欧美偷拍另类</a>| <a href="http://40346c.com" target="_blank">久热精品视频在线观看一区</a>| <a href="http://www-438686.com" target="_blank">欧美成人午夜</a>| <a href="http://aaddgg66.com" target="_blank">欧美一区深夜视频</a>| <a href="http://969093.com" target="_blank">欧美大片va欧美在线播放</a>| <a href="http://mmpzyw.com" target="_blank">性色av香蕉一区二区</a>| <a href="http://poqsoft.com" target="_blank">欧美成人嫩草网站</a>| <a href="http://www1122fu.com" target="_blank">久久超碰97中文字幕</a>| <a href="http://szxrdr.com" target="_blank">欧美大片一区二区三区</a>| <a href="http://797298.com" target="_blank">欧美亚洲专区</a>| <a href="http://987328.com" target="_blank">欧美极品一区二区三区</a>| <a href="http://305838.com" target="_blank">久久激情中文</a>| <a href="http://www-067.com" target="_blank">欧美乱妇高清无乱码</a>| <a href="http://www-8617.com" target="_blank">欧美一级一区</a>| <a href="http://sxxawef.com" target="_blank">欧美大片第1页</a>| <a href="http://saobi6.com" target="_blank">久久综合九色综合欧美狠狠</a>| <a href="http://1323666.com" target="_blank">欧美性色视频在线</a>| <a href="http://budanbao.com" target="_blank">亚洲高清不卡av</a>| <a href="http://9952222.com" target="_blank">国产一区二区三区久久精品</a>| <a href="http://goutoujunshi.com" target="_blank">91久久国产精品91久久性色</a>| <a href="http://9niuw.com" target="_blank">国产一区二区按摩在线观看</a>| <a href="http://www-37277.com" target="_blank">一个色综合导航</a>| <a href="http://66y3.com" target="_blank">日韩午夜三级在线</a>| <a href="http://khc83.com" target="_blank">美女福利精品视频</a>| <a href="http://www-232323.com" target="_blank">久久一日本道色综合久久</a>| <a href="http://sxhrdyb.com" target="_blank">国产精品少妇自拍</a>| <a href="http://749996.com" target="_blank">一区二区三区日韩欧美精品</a>| <a href="http://412342.com" target="_blank">久久久久久久国产</a>| <a href="http://www-78733.com" target="_blank">欧美在线视频在线播放完整版免费观看</a>| <a href="http://kkwwxx.com" target="_blank">农村妇女精品</a>| <a href="http://hhhtalk.com" target="_blank">男人插女人欧美</a>| <a href="http://www-188444.com" target="_blank">黄色成人av</a>| <a href="http://5588gww.com" target="_blank">亚洲欧美日韩在线高清直播</a>| <a href="http://72avav.com" target="_blank">亚洲自拍电影</a>| <a href="http://zj-jufeng.com" target="_blank">欧美日韩在线一区二区三区</a>| <a href="http://by2866.com" target="_blank">亚洲欧洲日本一区二区三区</a>| <a href="http://wlhtgj.com" target="_blank">亚洲区一区二</a>| <a href="http://wwwq4yy.com" target="_blank">欧美阿v一级看视频</a>| <a href="http://895658.com" target="_blank">欧美二区乱c少妇</a>| <a href="http://13751144594.com" target="_blank">亚洲激情另类</a>| <a href="http://lfxhfh.com" target="_blank">欧美激情第一页xxx</a>| <a href="http://04oy.com" target="_blank">亚洲黄色性网站</a>| <a href="http://www66617.com" target="_blank">亚洲日本中文字幕免费在线不卡</a>| <a href="http://rxbbei.com" target="_blank">久久久人人人</a>| <a href="http://www201314.com" target="_blank">欧美成人免费全部</a>| <a href="http://4c8x.com" target="_blank">91久久综合亚洲鲁鲁五月天</a>| <a href="http://ncncpa.com" target="_blank">女仆av观看一区</a>| <a href="http://038226.com" target="_blank">亚洲精品久久久久久久久久久</a>| <a href="http://wwwby2232.com" target="_blank">一区久久精品</a>| <a href="http://3374com.com" target="_blank">久久亚洲一区二区</a>| <a href="http://9a9u.com" target="_blank">亚洲国产精品成人一区二区</a>| <a href="http://yjsp8888.com" target="_blank">亚洲精品中文字幕在线观看</a>| <a href="http://qkspvip.com" target="_blank">欧美劲爆第一页</a>| <a href="http://7234hh.com" target="_blank">夜夜嗨av一区二区三区四区</a>| <a href="http://qiansemf.com" target="_blank">亚洲综合日韩中文字幕v在线</a>| <a href="http://2996611.com" target="_blank">国产精品初高中精品久久</a>| <a href="http://395493.com" target="_blank">亚洲一区二区在线视频</a>| <a href="http://www36633.com" target="_blank">久久国产精品亚洲77777</a>| <a href="http://bizhijidi.com" target="_blank">国产一区在线看</a>| <a href="http://kasimcoal.com" target="_blank">久久亚洲影音av资源网</a>| <a href="http://tzhbsb.com" target="_blank">亚洲精品国产拍免费91在线</a>| <a href="http://jxrisen.com" target="_blank">亚洲一区二区不卡免费</a>| <a href="http://bx989.com" target="_blank">国产精品自拍小视频</a>| <a href="http://aberyco.com" target="_blank">欧美一区二视频</a>| <a href="http://7749137.com" target="_blank">毛片一区二区</a>| <a href="http://luoliguo.com" target="_blank">99国产精品99久久久久久</a>| <a href="http://yytaotu.com" target="_blank">欧美视频在线免费</a>| <a href="http://huabiseeds.com" target="_blank">亚洲欧美www</a>| <a href="http://czhqwy.com" target="_blank">蜜桃精品一区二区三区 </a>| <a href="http://223zzz.com" target="_blank">久久久久久久久岛国免费</a>| <a href="http://fulong-tj.com" target="_blank">激情伊人五月天久久综合</a>| <a href="http://www-yh6.com" target="_blank">久久在线免费观看</a>| <a href="http://tristooges.com" target="_blank">亚洲激情亚洲</a>| <a href="http://caoliu2022.com" target="_blank">午夜精品一区二区三区在线视</a>| <a href="http://482b.com" target="_blank">国产精品伊人日日</a>| <a href="http://xzvaz.com" target="_blank">久久精品综合一区</a>| <a href="http://chengli88.com" target="_blank">亚洲国产精品一区二区www</a>| <a href="http://gaobb52.com" target="_blank">亚洲一区二区视频在线观看</a>| <a href="http://xy3977.com" target="_blank">国产午夜精品美女毛片视频</a>| <a href="http://bodabloc.com" target="_blank">麻豆91精品91久久久的内涵</a>| <a href="http://qkspvip.com" target="_blank">一本久道久久综合中文字幕</a>| <a href="http://mimi78.com" target="_blank">久久久久成人精品</a>| <a href="http://changjiucf.com" target="_blank">亚洲精品婷婷</a>| <a href="http://194123.com" target="_blank">国产免费观看久久</a>| <a href="http://www-878009.com" target="_blank">欧美freesex交免费视频</a>| <a href="http://wwwbbb888999.com" target="_blank">一本色道久久综合亚洲精品小说</a>| <a href="http://psykoptic.com" target="_blank">久久久精品动漫</a>| <a href="http://wwwnnnn.com" target="_blank">宅男噜噜噜66一区二区</a>| <a href="http://idc0558.com" target="_blank">伊人精品成人久久综合软件</a>| <a href="http://sxxawef.com" target="_blank">国产精品v欧美精品v日本精品动漫</a>| <a href="http://52sougou.com" target="_blank">久久久久久久综合</a>| <a href="http://05ec.com" target="_blank">一区二区三区不卡视频在线观看 </a>| <a href="http://jnjpsm.com" target="_blank">欧美~级网站不卡</a>| <a href="http://yh5557.com" target="_blank">亚洲视频一区二区</a>| <a href="http://05511253.com" target="_blank">国产精品视频xxx</a>| <a href="http://www-273111.com" target="_blank">免费欧美日韩</a>| <a href="http://tcgo903.com" target="_blank">亚洲欧美国产精品专区久久</a>| <a href="http://coerverbeijing.com" target="_blank">欧美国产日韩xxxxx</a>| <a href="http://pfpf662.com" target="_blank">欧美在线观看一区二区</a>| <a href="http://ahhyez.com" target="_blank">av成人天堂</a>| <a href="http://idc0558.com" target="_blank">亚洲国产91色在线</a>| <a href="http://2938476.com" target="_blank">国产情人节一区</a>| <a href="http://aqxiangtai.com" target="_blank">欧美日韩一区二区三区免费</a>| <a href="http://91keshi.com" target="_blank">久久夜色精品一区</a>| <a href="http://shno1steel.com" target="_blank">性久久久久久久久</a>| <a href="http://7115866.com" target="_blank">亚洲一级黄色av</a>| <a href="http://077229.com" target="_blank">亚洲精品视频在线播放</a>| <a href="http://www780yy.com" target="_blank">欧美大片一区</a>| <a href="http://wg135.com" target="_blank">噜噜噜在线观看免费视频日韩 </a>| <a href="http://www-76577c.com" target="_blank">亚洲高清三级视频</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>