pid to process descriptor

本文介绍了Linux系统中用于快速查找进程描述符的四种不同意义的PID及其对应的Hashtable机制。通过对hash函数及冲突解决方式的详细说明,揭示了Linux内核高效管理进程的技术细节。

为了能快速地将pid转为process descriptor的对应指针,linux维护了4个hash table,采用4个hash table的原因是因为对于每个进程,有4种不同意义的pid:
1.pid (进程的pid)
2.tgid ( pid of thread group leader process)
3.pgid ( pid of the group leader process)
4.sid ( sid pid of the session leader process)
hash table 所采用的hash function,代码如下:
unsigned long hash=val*0x9e370001UL;
return hash >> (32 - bits)
其中0x9e370001UL十进制为2654404609,来源于离pow(2,32)的黄金分割最近的素数,也就是离pow(2,32)*(pow(5,1/2)-1)/2最近的素数。
hash table采用的是list的方式来消除冲突,每个list项是一个process descriptor 结构。
2009/01/15 四

mowen@mowen-Default-string:~$ roslaunch astra_camera astrapro-FHD.launch ... logging to /home/mowen/.ros/log/a22ad2c4-6b66-11f0-a9af-00e18c435bc5/roslaunch-mowen-Default-string-30038.log Checking log directory for disk usage. This may take a while. Press Ctrl-C to interrupt Done checking log file disk usage. Usage is <1GB. started roslaunch server http://localhost:32877/ SUMMARY ======== PARAMETERS * /camera/camera_nodelet_manager/num_worker_threads: 4 * /camera/camera_rgb/camera_info_url: * /camera/camera_rgb/frame_rate: 30 * /camera/camera_rgb/height: 480 * /camera/camera_rgb/index: 0 * /camera/camera_rgb/product: 0x050f * /camera/camera_rgb/serial: 0 * /camera/camera_rgb/timestamp_method: start * /camera/camera_rgb/vendor: 0x2bc5 * /camera/camera_rgb/video_mode: mjpeg * /camera/camera_rgb/width: 640 * /camera/depth_rectify_depth/interpolation: 0 * /camera/depth_registered_rectify_depth/interpolation: 0 * /camera/driver/auto_exposure: True * /camera/driver/auto_white_balance: True * /camera/driver/bootorder: 0 * /camera/driver/color_depth_synchronization: False * /camera/driver/depth_camera_info_url: * /camera/driver/depth_frame_id: camera_depth_opti... * /camera/driver/depth_registration: True * /camera/driver/device_id: #1 * /camera/driver/devnums: 1 * /camera/driver/rgb_camera_info_url: * /camera/driver/rgb_frame_id: camera_rgb_optica... * /rosdistro: melodic * /rosversion: 1.14.13 NODES / camera_base_link (tf2_ros/static_transform_publisher) camera_base_link1 (tf2_ros/static_transform_publisher) camera_base_link2 (tf2_ros/static_transform_publisher) camera_base_link3 (tf2_ros/static_transform_publisher) /camera/ camera_nodelet_manager (nodelet/nodelet) camera_rgb (astra_camera/camera_node) depth_metric (nodelet/nodelet) depth_metric_rect (nodelet/nodelet) depth_points (nodelet/nodelet) depth_rectify_depth (nodelet/nodelet) depth_registered_hw_metric_rect (nodelet/nodelet) depth_registered_metric (nodelet/nodelet) depth_registered_rectify_depth (nodelet/nodelet) driver (nodelet/nodelet) points_xyzrgb_hw_registered (nodelet/nodelet) rgb_rectify_color (nodelet/nodelet) ROS_MASTER_URI=http://localhost:11311 process[camera/camera_rgb-1]: started with pid [30060] process[camera/camera_nodelet_manager-2]: started with pid [30061] process[camera/driver-3]: started with pid [30062] process[camera/rgb_rectify_color-4]: started with pid [30068] process[camera/depth_rectify_depth-5]: started with pid [30073] process[camera/depth_metric_rect-6]: started with pid [30075] process[camera/depth_metric-7]: started with pid [30086] [ INFO] [1753675024.783236664]: Initializing nodelet with 4 worker threads. process[camera/depth_points-8]: started with pid [30096] process[camera/depth_registered_rectify_depth-9]: started with pid [30101] [ INFO] [1753675024.820739456]: Device "2bc5/060f@1/46" found. process[camera/points_xyzrgb_hw_registered-10]: started with pid [30116] process[camera/depth_registered_hw_metric_rect-11]: started with pid [30121] process[camera/depth_registered_metric-12]: started with pid [30122] Warning: USB events thread - failed to set priority. This might cause loss of data... process[camera_base_link-13]: started with pid [30138] process[camera_base_link1-14]: started with pid [30144] process[camera_base_link2-15]: started with pid [30148] process[camera_base_link3-16]: started with pid [30150] [ INFO] [1753675024.924307602]: device name: Orbbec Astra Pro Plus unsupported descriptor subtype VS_COLORFORMAT attempt to claim already-claimed interface 1 [ WARN] [1753675025.732878688]: Unable to set scanning_mode to 0 [ WARN] [1753675025.734625796]: Unable to set auto_focus to 1 [ WARN] [1753675025.735170937]: Unable to set focus_absolute to 0 [ WARN] [1753675025.735894214]: Unable to set iris_absolute to 0 [ WARN] [1753675025.736701829]: Unable to set pantilt to 0, 0 [ WARN] [1753675025.962017071]: Camera calibration file /home/mowen/.ros/camera_info/camera.yaml not found. 出什么问题了
最新发布
07-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值