21、非阻塞并发的模块化终止验证

非阻塞并发的模块化终止验证

1. 引言

程序正确性的理解和证明问题自图灵时代就已被关注。证明程序时,不仅要确保其给出正确答案,还需保证程序能够终止,这对于并发程序而言尤为挑战。当多个线程修改共享资源时,每个线程是否终止往往依赖于其他线程的行为,甚至取决于调度器。

1.1 部分正确性与模块化方法

若仅证明并发程序能产生正确答案,这确立的是部分正确性。近年来,并发程序部分正确性的程序逻辑有诸多发展,这些逻辑强调模块化方法,将模块客户端的验证与其实现解耦,每个操作独立验证,推理局限于线程内部。它们抽象了线程与其环境间的干扰,适用于细粒度并发,特别是非阻塞算法。

1.2 非阻塞算法

非阻塞算法中,一个线程的挂起不会阻碍其他线程的进度。常见的非阻塞属性有等待自由和锁自由。等待自由要求操作无论其他线程干扰如何都能完成;锁自由则要求多个线程操作时至少有一个能取得进展。

1.3 总正确性与 Total - TaDA

若证明程序既产生正确结果又能在有限时间内完成,则确立了总正确性。图灵和弗洛伊德引入了良基关系结合部分正确性论证来证明顺序程序的终止,该技术也适用于并发程序。本文将 TaDA 扩展为 Total - TaDA,用于证明细粒度并发程序的总正确性。Total - TaDA 利用 TaDA 的抽象机制指定保证终止所需的环境约束,保留了 TaDA 的模块化特性。

1.4 TaDA 原子三元组

TaDA 引入了原子三元组的规范形式,支持局部、模块化推理并能表达对并发环境的约束。简单原子三元组形式如下:


        
从零构建简易Web服务器:Go/Python实现与生产级最佳实践 Web服务器是网络编程的核心组件,其本质是处理HTTP协议、管理并发连接并提供网络服务的软件。其工作原理基于I/O多路复用与事件驱动模型,通过高效调度连接资源实现高并发处理。掌握Web服务器实现技术,不仅能深入理解网络协议栈与操作系统交互,更能为构建高性能后端服务奠定坚实基础。在工程实践中,一个设计精良的简易Web服务器项目,是学习并发模型、协议解析和安全机制的绝佳载体。它聚焦核心功能的清晰实现,强调代码可读性与可维护性,尤其适合希望从“使用框架”进阶到“理解底层原理”的开发者。当前,社区高度关注web服务 阅读详情

相关推荐

Nginx架构及配置详解

概述 Nginx采用C进行编写,是俄罗斯程序员开发的一款轻量级的可构建Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器的软件, Nginx服务器是一个高性能的HTTP和反向代理web服务器,同时也可提供了IMAP/POP3/SMTP服务。nginx常用作跑静态和做负载反向代理,动态php交给apache处理,因后者比较稳定,jsp交给tomcat、resin或jboss。n......

企业实战系列集 ●●● https://ximenjianxue.blog.csdn.net 7085

计算机考研考博经典考题汇总(一次刷新世界观-我相信VIP总是有原因的)

操作系统 操作系统的特点? – 共享:资源可被多个并发执行的进程使用 – 并发:可以在同一时间间隔处理多个进程,需要硬件支持 – 虚拟:将物理实体映射成为多个虚拟设备 – 异步:进程执行走走停停,每次进程执行速度可能不同,但OS需保证进程每次执行结果相同 进程的三个组成部分? 程序段、数据段、PCB(Process Control Block) 并发与并行区别? 并发:同一间隔 并行:同一时刻 进程切换的过程? 保持处理机上下文 -> 更新PCB -> 把PCB移入相应队列(就绪、阻塞) -&g

weixin_44077556的博客 4万+

【信息科学与工程学】【数据中心】 第十九篇 MFU的优化提升方法01

MFU作为一个综合性能指标,清晰地揭示了下游任务(模型训练/推理)对上游计算资源(GPU集群)的实际利用效率。它不仅是技术能力的体现,更直接关系到企业的运营成本和AI创新的速度。追求更高的MFU,本质上是在有限的资源和无限的算力需求之间寻找最优解,是AI基础设施领域持续演进的核心动力。总而言之,数据中心CPU的MFU不仅仅是一个软件性能指标,它是计算芯片微架构、服务器硬件设计、数据中心基础设施以及软件算法协同工作效果的终极体现。

weixin_49199313的博客 1249

【信息科学与工程学】计算机科学与自动化——第二十篇 计算机体系架构00

路径选择与流量调度是网络优化中的核心环节,它们通过一系列算法来提升网络效率、降低延迟,并有效利用资源。

weixin_49199313的博客 809

【信息科学与工程学】【通信工程】第八十六篇 通信网络设备及通信网络组网的所有学科知识01

编号001类型网络虚拟化与覆盖技术网络领域数据中心网络子领域大二层网络 / 网络虚拟化核心数学方程式/算法模型核心算法:VXLAN封装与解封装。关键在于24位VNI(虚拟网络标识符)到物理网络的三层IP地址的映射。封装:收到原始以太帧后,为其添加 VXLAN 头部(含 VNI)、外层 UDP 头(目的端口 4789)、外层 IP 头(源 IP 为本地 VTEP IP,目的 IP 为对端 VTEP IP)以及外层 MAC 头。解封装:对端 收到报文后,剥离外层头部,根据内层帧的目的 MAC 和 VNI 进行二

weixin_49199313的博客 891

基于mbed TLS的嵌入式设备安全连接AWS IoT Core实战指南

在物联网(IoT)应用中,实现设备与云端的安全、可靠通信是核心挑战。TLS/SSL协议作为保障网络通信安全的基石,通过加密和身份验证机制,确保了数据在传输过程中的机密性与完整性。其技术价值在于为资源受限的嵌入式设备提供了轻量级的安全解决方案,广泛应用于智能家居、工业监控等场景。mbed TLS作为一个专为嵌入式系统设计的开源加密库,通过模块化设计和高度可配置性,使得在内存和计算能力有限的设备上实现TLS成为可能。本文将结合AWS IoT Core云平台,详细解析如何将mbed TLS库移植到LinkIt O

weixin_33912453的博客 278

Windows Server双机热备实战:用IIS+ARR+NLB搭建高可用Web服务(附避坑指南)

本文详细介绍了在Windows Server环境下,利用IIS、ARR(Application Request Routing)和NLB(Network Load Balancing)构建高可用Web服务的实战方案。通过双机热备架构,实现从网络层到应用层的全面冗余与智能流量分发,并提供了关键的配置步骤、常见避坑指南及性能调优建议,确保企业级Web服务的连续性与可靠性。

weixin_29210759的博客 394

aistudio高效解压zip文件的实用技巧

本文详细介绍了在百度AI Studio平台上高效解压ZIP文件的实用技巧。针对深度学习项目数据准备中的常见痛点,重点讲解了使用Python zipfile库和Linux unzip命令两种核心方法,并提供了路径设置、大文件处理、中文乱码等关键问题的解决方案,帮助用户提升数据处理效率。

salt的博客 801

西门子 G120 变频器报文

G120报文

mmxxoo_xxmmp的博客 8149

Delta并联机械手-Codesys实现以及正解逆解研究

由于Codesys的Robotics模块有Delta并联机械手的运动模型,因此借助Codesys的机械手运动模型,研究自己的正解逆解算法。

weixin_42386991的博客 5571

SQL中的时间计算:员工每日工作时长

摘要:本文介绍了一个使用SQL查询计算员工每日工作时长的实用方法。通过分析包含员工打卡记录的数据库表,利用CTE(公共表表达式)将日期分组,计算最早和最晚打卡时间差,最终以"小时:分钟"格式输出工作时长。该方法适用于每日两次打卡的场景,并提示了处理漏打卡等特殊情况时的注意事项,为企业考勤管理提供了有效的数据支持方案。(148字)

m0_74337424的博客 413

【DexGraspNet与多指手抓取算法详解】第三章 DexGraspNet数据集构建机理

抓取姿态描述多指手与物体的相对空间关系,包含手掌位姿与手指关节配置。

VectorShift的博客 503

STM32F407驱动OV2640摄像头全栈解析:DCMI+DMA+SCCB协同设计

图像采集是嵌入式视觉系统的基石,其核心在于传感器与MCU间的数据通路构建。原理上需理解并行接口(如DCMI)的硬件同步捕获机制、串行控制总线(如SCCB/I²C)的寄存器级配置逻辑,以及DMA在高吞吐数据搬运中的关键作用。技术价值体现在解放CPU、保障实时性、降低功耗,并支撑JPEG压缩与RGB565直显等差异化应用。典型场景包括智能终端实时预览、低带宽图像上传、工业现场视频监控及教学实验平台搭建。本文以STM32F407与OV2640集成实践为载体,深入剖析DCMI时序约束、SCCB软件模拟实现及DMA循

weixin_36151775的博客 185

一文探讨视频秒开:m3u8视频格式与视频秒开优化

秒开指的是,一秒内成功加载的播放数/播放总数。本意是想对比一下m3u8与mp4视频格式,并了解m3u8格式优缺点,以确定一个大概优化方向。但对m3u8做简单了解后,觉的m3u8可能是一个优化方向。

bjxiaxueliang的CODING小栈 2万+

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 39、模拟VLSI网络:设计与优化
下一篇: 13、探索生物启发认知架构的应用与发展
sql99
博客等级 码龄19年 171粉丝 1905原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址