Tcl在Unix/Linux环境下多线程支持环境搭建
来源:互联网 发布:apache 开启虚拟主机 编辑:程序博客网 时间:2024/05/18 13:25
一、 下载源码
tcl8.5 http://tcl.tk/software/tcltk/8.5.html
tclThread2.6 http://core.tcl.tk/thread/info/2e574064a4
二、安装tcl8.5
tar -xvf tcl8.5.9-src.tar.gzcd tcl8.5.9cd unix./configure --prefix=$HOME/tools/tcl8.5.9 --enable-threadsmake ; make install
注:要支持tcl多线程必须加编译选项 --enable-threads
三、 安装tclThread2.6
unzip tclthread2.6.zipcd tclthread2.6configure --with-tcl=$HOME/sft/tcl8.5.9/unix --prefix=$HOME/tools/tcl8.5.9/lib/tcl8.5make ; make install
注:编译tclthread2.6时需要配置文件tclconfig,这个配置文件可以从其他安装包中获取 如mysqltcl-3.05/tclconfig。
其实目录tclconfig下有一个安装脚本名为:install-sh,内容如下:
#!/bin/sh## install - install a program, script, or datafile# This comes from X11R5; it is not part of GNU.## $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $## This script is compatible with the BSD install script, but was written# from scratch.## set DOITPROG to echo to test this script# Don't use :- since 4.3BSD and earlier shells don't like it.doit="${DOITPROG-}"# put in absolute paths if you don't have them in your path; or use env. vars.mvprog="${MVPROG-mv}"cpprog="${CPPROG-cp}"chmodprog="${CHMODPROG-chmod}"chownprog="${CHOWNPROG-chown}"chgrpprog="${CHGRPPROG-chgrp}"stripprog="${STRIPPROG-strip}"rmprog="${RMPROG-rm}"instcmd="$mvprog"chmodcmd=""chowncmd=""chgrpcmd=""stripcmd=""rmcmd="$rmprog -f"mvcmd="$mvprog"src=""dst=""while [ x"$1" != x ]; do case $1 in-c) instcmd="$cpprog" shift continue;;-m) chmodcmd="$chmodprog $2" shift shift continue;;-o) chowncmd="$chownprog $2" shift shift continue;;-g) chgrpcmd="$chgrpprog $2" shift shift continue;;-s) stripcmd="$stripprog" shift continue;;*) if [ x"$src" = x ] thensrc=$1 elsedst=$1 fi shift continue;; esacdoneif [ x"$src" = x ]thenecho "install: no input file specified"exit 1fiif [ x"$dst" = x ]thenecho "install: no destination specified"exit 1fi# If destination is a directory, append the input filename; if your system# does not like double slashes in filenames, you may need to add some logicif [ -d $dst ]thendst="$dst"/`basename $src`fi# Make a temp file name in the proper directory.dstdir=`dirname $dst`dsttmp=$dstdir/#inst.$$## Move or copy the file name to the temp name$doit $instcmd $src $dsttmp# and set any options; do chmod last to preserve setuid bitsif [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fiif [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fiif [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fiif [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi# Now rename the file to the real destination.$doit $rmcmd $dst$doit $mvcmd $dsttmp $dstexit 0
四、测试脚本验证tcl的多线程。
package require Threadputs "*** I'm thread [thread::id]"# Create 3 threadsfor {set thread 1} {$thread <= 3} {incr thread} {set id [thread::create {# Print a hello message 3 times, waiting# a random amount of time between messagesfor {set i 1} {$i <= 3} {incr i} {after [expr { int(500*rand()) }]puts "Thread [thread::id] says hello"}}] ;# thread::createputs "*** Started thread $id"} ;# forputs "*** Existing threads: [thread::names]"# Wait until all other threads are finishedwhile {[llength [thread::names]] > 1} {after 500}puts "*** That's all, folks!"
运行结果:
*** I'm thread tid000005EC*** Started thread tid000016E8*** Started thread tid00000100*** Started thread tid00001260*** Existing threads: tid00001260 tid00000100 tid000016E8 tid000005ECThread tid00000100 says helloThread tid000016E8 says helloThread tid00001260 says helloThread tid00000100 says helloThread tid00000100 says helloThread tid000016E8 says helloThread tid00001260 says helloThread tid00001260 says helloThread tid000016E8 says hello*** That's all, folks!
- Tcl在Unix/Linux环境下多线程支持环境搭建
- linux下搭建unix编译环境
- 搭建Unix Linux 学习环境
- 如何在unix c++环境下创建多线程呢?
- 原创Linux下搭建Nginx环境的搭建(支持正则)
- 在Linux环境下面搭建 UNIX 环境高级编程(第三版) 的代码编译环境
- 在Linux下搭建Web应用环境
- 在Linux下搭建Fortran开发环境
- 在Linux下搭建 jsp 环境配置
- bochs在Linux下的环境搭建
- 在linux下搭建libcap开发环境:
- 在Linux下搭建Java环境
- 在linux下搭建wiki环境
- 在Linux下搭建 miniGUI mStudio环境
- 在LINUX下搭建JAVA开发环境
- qt 在linux环境下的搭建
- 在Linux下搭建RoR运行环境
- 在 Linux 下搭建 Java 开发环境
- EBS在后台取消请求
- linux wall命令详解
- android ListView监听滚动条滚动到底部时继续加载
- 第一篇博客
- android项目窗口布局属性介绍
- Tcl在Unix/Linux环境下多线程支持环境搭建
- AT扩展指令集
- 今天花一上午时间写的快速排序算法,自己娱乐了
- 解读成功他妈:【失败团队的10个特征】
- oracle常用语句 索引、列操作
- Libgdx中使用Box2D 坐标系问题
- 公共语言运行时的另外一个作用是可以轻松地实现跨平台。当然,条件是要在操作系统 上安装.NET Framework
- sqlserver 2008 无法使用特殊主体‘sa’,错误15405
- linux下基于jrtplib库的实时传送实现