在Tcl中,来自多个线程的段错误需要Expect [英] In Tcl, seg faults from multiple threads requiring Expect

查看:96
本文介绍了在Tcl中,来自多个线程的段错误需要Expect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,这很有趣.当Tcl中有多个线程调用 package require Expect 时,出现段错误.

Now here's something interesting. When I have more than one thread in Tcl invoking package require Expect, I get a seg fault.

例如

package require Threads  
package require Expect

set t [thread::create]

thread::send {package require Expect}

puts "blarg! Damned thing crashes before I get here"

这不是一个好时机.有什么想法吗?

This is not a good time. Any thoughts?

推荐答案

期望和线程并不太好.它从fork()+线程中获取的复杂性可能会在其中大量咬住并导致死锁和各种丑陋.通常,将两者结合起来并不是一个好主意.

Expect and Threads don't go together too well. Its the complexity you get from fork() + threads that can bite a lot there and lead to deadlocks and all kinds of uglyness. Usually not a good idea to combine the two.

如果您确实需要Expect和增加的并发性,那么在多线程驱动程序和一个单线程的Expect进程上使用多进程方法可能会更好.如果您使用的是tcllibs comm软件包,则用于发送命令的api也没有太大的不同(如果您使用comm,您通常会错过tsv和tpool的东西).

If you really need Expect and the added concurrency a multi process approach with on multi threaded driver program and one single threaded expect process might work better. If you used tcllibs comm package the api's for sending commands are not that much different either (you mostly miss the tsv and tpool stuff if you used comm).

但是,它不应该确定是否存在段错误.您使用了哪种Expect/Threads/Tcl核心组合(例如ActiveStates ActiveTcl捆绑包或在不寻常的平台上进行一些自编译的东西?)

But it shouldn't segfault for sure. Which Expect/Threads/Tcl core combination did you use (e.g. ActiveStates ActiveTcl bundle or some self compiled stuff on an unusual platform?)

这篇关于在Tcl中,来自多个线程的段错误需要Expect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆