-
linux epoll模型
该代码是关于在linux平台下的网络编程,epoll模型,socket接受线程:C语言为了高并发所以选择了epoll。当程序启动的时候(g_net_update.c文件中main函数,会启动一个thread见函数create_accept_task)这个thread就处理一件事情,只管接收客户端的连接,当有连接进来的时候 通过epoll_ctl函数,把socket fd 加入到epoll里面去,epoll设置监听事件EPOLLIN | EPOLLET; 主要是监听的是加入到epoll中的socket是否可读(因为我的需求是客户端连上了server就会马上向server发送一份数据的)。其它的部分在主线程中处理。主线程:是一个无线循环,epoll_wait 函数相当于把客户端的连接从epoll中拿出来(因为我们监听的是EPOLLIN | EPOLLET)说明这个时候客户端有数据发送过来)。再通过recv_buffer_from_fd 函数把客户端发送过来的数据读出来。然后其他的一切就抛给线程池去处理。线程池:(代码中我会在池里面创建15个线程) 双向链表。加入线程就是在链表后面加一个链表项,链表的前面会一个一个被拿出来处理。主要是malloc 函数free函数,sem_wait函数sem_post的处理(sem_wait 会阻塞当值大于0是会减一,sem_post是值加一)。typedef void* (FUNC)(void arg, int index);是我们自定义的线程的逻辑处理部分,arg是参数,index是第几个线程处理(我们隐形的给每个线程都标了号),例如代码中的respons_stb_info,更加具体可以看看代码里面是怎么实现的。聪明的你也可以改掉这块的内容改成动态线程池,当某个时刻的处理比较多的时候能够动态的增加线程,而不像我代码里面的是固定的。数据库连接池:按照我的需求在处理客户端请求数据的时候是要访问数据库的。就是一下子创建出一堆的数据连接。要访问数据库的时候先去数据库连接池中找出空闲的连接,具体可以看下代码。使用的时候可以参考下database_process.c文件(代码中数据库连接池和线程池中的个数是一样的)。
- 2022-03-20 03:15:54下载
- 积分:1
-
人工神经网络的工具想函数一览表,可以查询很方便的
人工神经网络的工具想函数一览表,可以查询很方便的-artificial neural network tool to the list of functions that can be very convenient inquiry
- 2022-12-16 06:45:03下载
- 积分:1
-
SL030, 13.56M micro and small to read and write documentation module, antenna an...
SL030,13.56M微小型读写模块说明文档,天线与模块集成到一块小板-SL030, 13.56M micro and small to read and write documentation module, antenna and module integrated into a small plate
- 2022-05-14 20:10:47下载
- 积分:1
-
关于卡尔曼滤波和等增益滤波器的仿真源码,给出了他们的性能比较,很实用的程序...
关于卡尔曼滤波和等增益滤波器的仿真源码,给出了他们的性能比较,很实用的程序-Such as Kalman filtering and the gain on the filter simulation source code, given their performance comparison, a very useful program
- 2022-01-26 00:19:20下载
- 积分:1
-
用于实现单目标跟踪的仿真。采用单传感器单目标的方式,介绍了基本的数据关联方法。...
用于实现单目标跟踪的仿真。采用单传感器单目标的方式,介绍了基本的数据关联方法。-Used to achieve single-target tracking simulation. Single-sensor single-objective way to introduce the basic method of data association.
- 2022-05-06 19:10:12下载
- 积分:1
-
Generates the filtered BPSK and plots the spectrum
Generates the filtered BPSK and plots the spectrum
- 2023-06-13 23:15:03下载
- 积分:1
-
pracsim是仿真模型和互连结构的模拟…
pracsim是一个由仿真模型和可互连的仿真结构组成的模块集,为用户提供一个可修改及开发的基础模型,其他为附属文件。-pracsim is a simulation model and the simulation of interconnection structure of the module set, to provide users with a revised and the development of the model, other subsidiary documents.
- 2023-05-15 02:20:04下载
- 积分:1
-
图像去模糊处理项目
image processing deblurring project
- 2022-07-01 04:29:43下载
- 积分:1
-
OPC document,collecting~
OPC document,collecting~
- 2023-08-26 18:40:04下载
- 积分:1
-
jtag上位机源程序,遵循JTAG通信协议,用于带JTAG芯片的调试。...
jtag上位机源程序,遵循JTAG通信协议,用于带JTAG芯片的调试。-JTAG host computer source code, follow the JTAG communication protocol for the chip with JTAG debugging.
- 2022-01-25 21:51:29下载
- 积分:1