, the kernel to dispatch other process to run, passive loses CPU. (Hangs can be preempted by another process, causing it to hang, or to suspend itself on its own initiative.) ) 5 I/O models available under UNIX: 1, blocking I/O 2, non-blocking I/O 3,i/o multiplexing 4, signal-driven I/O (SIGIO) 5, asynchronous i/o1--4 for synchronous i/o,5 for asynchronous I/O. The I/O multiplexing we are concerned with is synchronous I/O, which causes the process to
slow. Therefore, select often has a managed handle cap (fd_setsize). At the same time, on use, because only one field records attention and events, the Fd_set struct is reinitialized before each call.int Select(int Nfds, Fd_set *Readfds, Fd_set *Writefds, Fd_set *Exceptfds, struct Timeval *Timeout);
Idea: There is a connection request arrived at the re-check processing.
Problem: Handle upper bound + repeat initialization + one-by-one troubleshooting all file handle states are ineff
function, regardless of whether the file descriptor is changed, immediately return to continue execution, the file has no change return 0, there is a change to return a positive value; Timeout value is greater than 0, this is the waiting time-out period, that is, select in timeout time block, the timeout period has the arrival of the event to return, otherwise after the timeout, anyway must return, the return value with the above.return value:Negative value: Select Error positive value: Some fi
method is the arrival of poll listening request, and then the accept out New_sock, the new_sock to a new thread, then the task is this child thread: voidhandle_connection_sockets () {intSocket_count =0; //Yes, just two, a ip_sock, a unix_sock, the former is used to accept the remote client, the latter is used to accept the machinePOLLFD fds[2]; FDS[SOCKET_COUNT].FD=Ip_sock;
function immediately returns to continue execution regardless of whether the file descriptor has changed. If the file does not change, 0 is returned and a positive value is returned. Third, the value of timeout is greater than 0, this is waiting.Timeout time, that is, the SELECT statement is blocked within the timeout time. If an event arrives within the time-out time, it is returned. Otherwise, no matter how long it is returned, the return value is the same as the above.Return Value:Negative v
collection of monitored file descriptors changes. Second, if the time value is set to 0 s and 0 ms, it becomes a pure non-blocking function,No matter whether the file descriptor changes or not, the system immediately returns the code to continue execution. If the file does not change, 0 is returned, and a positive value is returned. Third, the value of timeout is greater than 0, which is the waiting timeout time, that isThe SELECT statement is blocked within the time-out period. If an event arr
, it must wait until a file descriptor in the collection of monitored file descriptors changes. Second, if the time value is set to 0 s and 0 ms, it becomes a pure non-blocking function,No matter whether the file descriptor changes or not, the system immediately returns the code to continue execution. If the file does not change, 0 is returned, and a positive value is returned. Third, the value of timeout is greater than 0, which is the waiting timeout time, that isThe SELECT statement is blocke
Linux IPC (Inter-Process Communication, Inter-process Communication) pipeline learning, ipcinter-Process1. the standard Stream pipeline operation supports the file stream mode, which is used to create the pipeline linking another process. This blog introduces the function popen and pclosepopen in detail. 2. unknown pipeline (PIPE) features: 1) communication can only be performed between kinship processes (Parent and Child or brother) 2) Half Duplex (fixed read end and fixed write end) 3) it is a
.
Example:
Main ()
{
Int sock;
File * FP;
Struct fd_set FDS;
Struct timeval timeout = {3, 0}; // select wait 3 seconds, 3 seconds round-robin, set to 0 if it is not blocked
Char buffer [256] = {0}; // receiving buffer of 256 bytes
/* Assume that a UDP connection has been established, and the specific process is not written or simple. Of course, the same applies to TCP. The host IP address and port are already specified, and the file to be written has
;Struct timeval TV;FD_ZERO ( rfds );FD_SET (fd, rfds );TV. TV _sec = 1;TV. TV _usec = 0;Select_ret = select (fd + 1, rfds, NULL, NULL, TV );Return select_ret;}After the preceding select statement is called, it will be called to do_select in the kernel, which will block:Int do_select (int n, fd_set_bits * fds, struct timespec * end_time){Ktime_t expire, * to = NULL;Struct poll_wqueues table;Poll_table * wait;Int retval, I, timed_out = 0;Unsigned lon
);Fd_set (FD, rfds);Tv.tv_sec = 1;tv.tv_usec = 0;Select_ret = Select (FD + 1, rfds, NULL, NULL, AMP;TV);return select_ret;}When select is called above, it is called to Do_select in the kernel, which blocks:int do_select (int n, fd_set_bits *fds, struct timespec *end_time){ktime_t expire, *to = NULL;struct Poll_wqueues table;Poll_table *wait;int retval, I, timed_out = 0;unsigned long slack = 0;Rcu_read_lock ();retval = MAX_SELECT_FD (n,
Usually I like Linux more than BSD system, but I really want to have BSD Kqueue function on Linux.What is event multiplexing technologySuppose you have a simple Web server, and there are two socket connections open there. When the server receives an HTTP request from both connections, it should return an HTTP response to the client. But you can't know the message that the client sent first and when it was sent. The blocking behavior of the BSD socket interface means that if you call the recv ()
, here no longer repeat, simply say SSD to use Noop,sata/sas deadline.
echo"deadline" > /sys/block/sd[x]/queue/schedulerecho"noop" > /sys/block/sd[x]/queue/scheduler
Cgroup
This article seems to be less, yesterday in the process of communication with the Ceph community, Jan Schermer said he was prepared to contribute to some of the scripts in the production environment, but for the time being, he also cited some of the reasons for using Cgroup for isolation.
Not
: Support through the Web page to face the task of crud operations, simple operation, one minute to start;
2, Dynamic: Support the dynamic modification of task status, Suspend/restore tasks, and terminate the operation of the task, immediate effect;
3, the dispatch center Ha (center type): The dispatch uses the center type design, "The Dispatch center" is based o
IOS GCD User Guide
Grand Central Dispatch (GCD) is one of the technologies used to execute tasks asynchronously. Generally, the code used for thread management described in the application is implemented in the system level. Developers only need to define the tasks they want to execute and append them to the appropriate Dispatch Queue. Then, GCD can generate necessary threads and schedule the tasks to be ex
IOS GCD User GuideGrand Central Dispatch (GCD) is one of the techniques for performing tasks asynchronously. The code for thread management described in the application is generally implemented at the system level. Developers only need to define the tasks they want to perform and append them to the appropriate dispatch queue, GCD can generate the necessary threads and plan to perform the task. Because threa
IOS GCD User Guide and iosgcd User Guide
Grand Central Dispatch (GCD) is one of the technologies used to execute tasks asynchronously. Generally, the code used for thread management described in the application is implemented in the system level. Developers only need to define the tasks they want to execute and append them to the appropriate Dispatch Queue. Then, GCD can generate necessary threads and sched
write the file has been opened sock=socket (...); bind (...); fp=fopen (...); */ while (1) { fd_zero (fds) //to empty the collection every time the loop is not detected, the descriptor changes fd_set (Sock,fds); //Add descriptor fd_set (Fp,fds) //ditto NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;NBSP;MAXFDP=SOCKGT;FP?SOCK+1:FP +1;//descriptor Max plus 1 switch
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.