PHP None-Thread Safe与Thread Safe(非线程安全与线程安全)版本的选择

发布:聚友 日期:2009年7月24日

从PHP5.2.10版本开始(现在有PHP5.2.10和5.3两个版本),有None-Thread Safe与Thread Safe两种版本的可供选择,这两种版本有何不同,作为使用者来说又应该如何选择呢?下面聚友将为您讲述。

先从字面意思上理解,None-Thread Safe就是非线程安全,在执行时不进行线程(thread)安全检查;Thread Safe就是线程安全,执行时会进行线程(thread)安全检查,以防止有新要求就启动新线程的 CGI 执行方式耗尽系统资源。

再来看PHP的两种执行方式:ISAPI和FastCGI。FastCGI执行方式是以单一线程来执行操作,所以不需要进行线程的安全检查,除去线程安全检查的防护反而可以提高执行效率,所以,如果是以 FastCGI(无论搭配 IIS 6 或 IIS 7)执行 PHP ,都建议下载、执行 non-thread safe 的 PHP (PHP 的二進位檔有兩種包裝方式:msi 、zip ,請下載 zip 套件)。而线程安全检查正是为ISAPI方式的PHP准备的,因为有许多php模块都不是线程安全的,所以需要使用Thread Safe的PHP。

说到这里,大家应该知道应该如何选择哪个版本的PHP了。None-Thread Safe or Thread Safe,您会选择哪个?

 

 

 

 

Since the release of PHP 5.2.1 back in Feburary there has been two new binary packages available for Windows, the non thread safe PHP binaries and the non thread safe PECL binaries. Since then I've read many threads in Internet forums where there seems to be a bit of confusion on what these extra binaries are, how they are used, and what effect they have. In this article I'll discuss the pro's and con's of these new binaries.

Since PHP first came to Windows back on the 20th of October 2000 with the release of PHP 3.0.17, the Windows binaries have always been released as thread safe packages. The reason for this is that Windows uses a multi threaded architecture as opposed to the multi proccess architecture of Linux and Unix. The problem this has when using PHP on IIS in CGI mode is that it makes it very slow as CGI was built on a multi process model, not a multi threaded model. On the flip side the problem this has when using PHP on IIS with the much faster ISAPI module is that there are several popular PHP extensions that have been developed with only Unix/Linux in mind (multi proccess model), and actually cause the PHP ISAPI module to crash on IIS. This making CGI the most stable environment for PHP on IIS, with the major disadvantage that it is terribly slow due to it having to load and unload the entire PHP environment from memory everytime there is a request.

There have been a few options available for a while to get PHP performing well on IIS. Firstly is the use of an opcode cache such as eAccelerator which stores PHP scripts in a partically precompiled state on disk and/or memory which drastically decreases script execution time. Another option is to configure IIS to use PHP in FastCGI mode which allows PHP processes to be recycled rather than killed off after each PHP request and also allows you to run several PHP processes at once, making PHP much much faster with the added bonus that as it is using the CGI interface there is little or no incompatibility issues with PHP extensions. This is still the fastest way to serve PHP, and is the way the IIS Aid PHP Installer is configured to install PHP on your IIS Environment.

What the non thread safe binaries allow you to do is to configure IIS (and other Windows based webservers) to use PHP as a standard CGI interface with massively increased performance as the PHP process is not required to wait for thread syncronisation. The performance increase is not to be sneezed at either as I've seen figures of upto 40% mentioned (though I'm yet to confirm myself), but it is still not as fast as the opcode/FastCGI method mentioned above. One of the biggest catches I've seen people getting themselves hooked on is that non thread safe binaries cannot be reliably used with the thread safe ones, and vise versa. This means that (for the moment at least) you cannot use opcode cache systems such as eAccelerator to give your non thread safe PHP environment a boost in the arm as they are all currently compiled as thread safe.

If the non thread safe binaries are not as fast as what you can configure the thread safe binaries to be then what is the point you ask? Here we come back to FastCGI, and in particular the efforts Microsoft have been making over the last year or so with the development of their own FastCGI handler. This new FastCGI handler from Microsoft enables you to configure the non thread safe PHP binaries in FastCGI mode, which is one massive shot in the arm for performance. Easiest way to put it is using the non thread safe PHP binaries with Microsoft's new FastCGI handler is like putting twin turbos on your car (without the inherent risk of blowing up your engine), and there is little doubt in my mind that this will be the future of PHP on IIS.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: gcc-arm-none-eabi是针对ARM架构的嵌入式系统开发的GNU工具链。它是ARM公司官方推荐的工具链之一,常用于开发ARM Cortex-M系列微控制器。gcc-arm-none-eabi的版本命名规则是X.Y.Z,其中X表示主版本号,Y表示次版本号,Z表示修订号。 以gcc-arm-none-eabi-9-2019-q4-major为例,其中9表示主版本号,2019表示年份,q4表示季度(第4季度),major表示此版本是主要版本版本号的更迭主要是为了修复一些已知的漏洞和错误,增加新功能和优化性能。每个版本都可能有一些兼容性的变化,以及对新硬件的支持。因此,选择正确的gcc-arm-none-eabi版本是很重要的,以确保代码的正确编译和运行。 在选择gcc-arm-none-eabi版本时,可以考虑以下几个因素: 1. 目标平台:确保选择版本支持目标平台的处理器架构和指令集。 2. 功能需求:查看版本发布说明,了解该版本是否具有您需要的新功能或改进。 3. 兼容性:与其他软件工具(如调试器、RTOS等)的兼容性,确保它们能够配合使用。 4. 社区支持:查看开源社区中对该版本的评价和反馈,了解其稳定性和可靠性。 总之,选择合适的gcc-arm-none-eabi版本是进行ARM嵌入式系统开发的重要环节,需要仔细考虑目标平台和功能需求,确保开发过程和项目的顺利进行。 ### 回答2: gcc-arm-none-eabi是一款针对ARM架构的嵌入式系统开发工具链。它是GNU开发工具链的一部分,专门用于编译ARM处理器的裸机程序或嵌入式系统代码。gcc-arm-none-eabi提供了C、C++和汇编语言的编译器,以及链接器、调试器和其他开发工具。它支持多种ARM处理器系列,包括Cortex-M系列和Cortex-R系列。 gcc-arm-none-eabi的版本号表示了工具链的发布版本。例如,版本为9-2020-q2-update表示是在2020年第二季度发布的第9版更新。不同版本的gcc-arm-none-eabi可能会包含不同的功能改进和修复,例如增强的编译器优化、新的设备支持和更好的调试功能。 选择合适的gcc-arm-none-eabi版本对于开发嵌入式系统常重要。在选择版本时,一方面需要考虑所需的功能和设备支持,另一方面也要考虑与其他工具和库的兼容性。通常建议使用最新的稳定版本,以确保能够获得最新的功能和修复。 为了使用gcc-arm-none-eabi,我们首先需要将其安装在开发环境中,并设置好相应的环境变量。然后,我们可以使用gcc命令来编译和链接程序,并使用调试器进行调试。gcc-arm-none-eabi还提供了一些其他的工具,如objdump和gdb,用于查看和分析编译后的程序。 总之,gcc-arm-none-eabi是一款强大的嵌入式系统开发工具链,它提供了编译器、链接器和调试器等工具,用于开发ARM架构的裸机程序和嵌入式系统代码。选择适合的版本对于开发嵌入式系统至关重要,开发者可以根据需求选择最新的稳定版本。 ### 回答3: gcc-arm-none-eabi是GNU Compiler Collection (GCC) 的一个特殊版本,专门用于嵌入式系统开发,特别是针对使用ARM处理器的嵌入式设备。 根据具体的版本号来选择gcc-arm-none-eabi的版本是很重要的,因为每个版本都可能有不同的特性和优化。以下是一些常见的gcc-arm-none-eabi版本: 1. gcc-arm-none-eabi 4.x.x:这是早期版本,通常用于ARM处理器的较早的系列,如ARMv7和较旧的ARM Cortex-M系列。这些版本可能不支持一些新的ARM指令集和优化,但它们在大多数嵌入式应用中仍然很常见。 2. gcc-arm-none-eabi 5.x.x:这是较新的版本,支持更多ARM指令集和优化。它适用于绝大多数ARM Cortex-M系列处理器,包括较新的Cortex-M3、Cortex-M4和Cortex-M7。 3. gcc-arm-none-eabi 6.x.x:这是进一步改进和优化的版本,提供更好的性能和代码生成质量。它通常用于最新的ARM Cortex-M系列,如Cortex-M4、Cortex-M7和最新的Cortex-M33。 4. gcc-arm-none-eabi 7.x.x:这是当前正在积极开发和维护的版本,为最新的ARM Cortex-M系列提供了广泛的支持,并且还有一些新的优化和特性。这个版本被认为是ARM嵌入式开发的首选版本。 通过选择最适合目标设备的gcc-arm-none-eabi版本,开发者能够充分利用特定版本所提供的功能和改进,以获得更好的性能和更高的代码生成质量。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值