由买买提看人间百态

topics

全部话题 - 话题: pthreads
1 2 3 4 5 6 7 8 下页 末页 (共8页)
p***o
发帖数: 1252
1
来自主题: Programming版 - pthread and C++
What do you mean? A C++ version of pthread? I don't think pthread people
would put any effort toward that. It makes more sense to port pthread to
every platform.
There are quite some cross-platform C++ thread libraries, which will use
pthread on platforms with pthread, like Zthread and ACE.

thread programming in C++ much easier. Is there any effort on pthread by
POSIX or organizations? After all, the pthread is used broadly by programers.
E*****7
发帖数: 128
2
来自主题: Programming版 - Pthread support on Windows XP
I want to use Pthread to do multithreading on Windows XP and found pthreads-
win32 as follows:
http://sourceware.org/pthreads-win32/
Is there anybody here who know how to set it up on Windows XP for playing
with pthread multithread programming? Thanks.
O*******d
发帖数: 20343
3
来自主题: Programming版 - 弱问一句关于pthread的
You should set linker path to where pthread library is, not where the header
is.
http://www.hotscripts.com/forums/c-c/35895-help-pthreads-dev-c.html
Here is a web page about pthread library. Look at Q2.
http://sourceware.org/pthreads-win32/faq.html

setting
w***g
发帖数: 5958
4
来自主题: Programming版 - gcc编译选项 -lpthread vs -pthread
-phtread是指让编译器在实现某些并行功能的时候产生使用pthread的代码,
隐含-lphtread. gcc似乎只有openmp依赖这个,并且-fopenmp隐含-pthread.
但是g++在编译某些C++并行功能的时候(比如std::async), 是否用
-pthread出来的效果是不一样的.我印象中如果不加-pthread,
std::launch::async是不起作用的,即使加了-lpthread也没用.
i**p
发帖数: 902
5
来自主题: Programming版 - pthread and C++
No necessary of a C++ version, but a class wrapper of pthread library, for
example,
Class My_class : public Pthread {
...
}
My_class my;
my.create();
..
Did you mean Zthread is implemented by pthread underneath?

programers.
p**p
发帖数: 3386
6
来自主题: Programming版 - 对pthread熟悉的XD请进来看看
想用pthread实现Producer/Consumer模型,但要避免polling的出现。因为这样反复检
查一个变量以判断是否有data被producer生成的话,系统占用率会很高,大量CPU时间
都浪费在轮询上了。
研究了一下pthread,里面的condtion variable好像可以用来同步线程。但发现只
有pthread_cond_wait和pthread_cond_signal两个主要函数,一个用来等某个条件
,另一个用来发出该条件。找了半天没看到如何取消该条件来导致线程重新进入等
待状态。也就是说,比如用户A等待某个condition,然后B激活该condition,A被唤
醒,完成工作,下面想让该condition被取消,这样A继续能够用pthread_cond_wai
t来睡眠直到condition重新被激活为止。
如果只用pthread_cond_wait和pthread_cond_signal两个函数的话,用户一旦被唤
醒就不可能再被催眠了,这样就没法达到设计的目的。
对pthread还没吃透,哪位DX给点建议或者link?多谢!
k****y
发帖数: 781
7
Let's say pthread #1 belongs to process #1. How to use pthread mutex to
protect share resources between process #1 and pthread #1.
l******9
发帖数: 579
8
Hi,
I am trying to do parallelization for a computing intensive problem.
I am working on a Linux cluster where each node is a multicore processor.
e.g. 2 or 4 quad-core processor per node.
I want to reduce latency and improve performance as much as possible.
I plan to use multiprocessing and multithreading at the same.
Each process run on a distinct node and each process spawn many threads
on each node. This is a 2 level parallelism.
For multiprocessing, I would like to choose MPI.
For multithre... 阅读全帖
l******9
发帖数: 579
9
Hi,
I am trying to do parallelization for a computing intensive problem.
I am working on a Linux cluster where each node is a multicore processor.
e.g. 2 or 4 quad-core processor per node.
I want to reduce latency and improve performance as much as possible.
I plan to use multiprocessing and multithreading at the same.
Each process run on a distinct node and each process spawn many threads
on each node. This is a 2 level parallelism.
For multiprocessing, I would like to choose MPI.
For multithre... 阅读全帖
l******9
发帖数: 579
10
Hi,
I am trying to do parallelization for a computing intensive problem.
I am working on a Linux cluster where each node is a multicore processor.
e.g. 2 or 4 quad-core processor per node.
I want to reduce latency and improve performance as much as possible.
I plan to use multiprocessing and multithreading at the same.
Each process run on a distinct node and each process spawn many threads
on each node. This is a 2 level parallelism.
For multiprocessing, I would like to choose MPI.
For multithre... 阅读全帖
i**p
发帖数: 902
11
来自主题: Programming版 - pthread and C++
How? Is there Thread class in pthread library? or I have to call pthread C
library in my C++ code?
i**p
发帖数: 902
12
来自主题: Programming版 - pthread and C++
The Zthread provides the multi-threading Class Library, which makes the thread programming in C++ much easier. Is there any effort on pthread by POSIX or organizations? After all, the pthread is used broadly by programers.
d****i
发帖数: 4809
13
来自主题: Programming版 - 弱问一句关于pthread的
在Windows的Visual Studio中怎么编译pthread的程序?似乎VS不默认pthread.h中所有
定义的库函数。
d****i
发帖数: 4809
14
来自主题: Programming版 - 弱问一句关于pthread的
请问怎么给linker加上pthread的库?在VS中如何设置,我试了一下在project setting
里面linker选项中additional library directory加了pthread.h所在的路径,还是不
工作。多谢,问题实在有点初级。
l******9
发帖数: 579
15
Hi,
I am trying to do parallelization for a computing intensive problem.
I am working on a Linux cluster where each node is a multicore processor.
e.g. 2 or 4 quad-core processor per node.
I want to reduce latency and improve performance as much as possible.
I plan to use multiprocessing and multithreading at the same.
Each process run on a distinct node and each process spawn many threads
on each node. This is a 2 level parallelism.
For multiprocessing, I would like to choose MPI.
For multithre... 阅读全帖
t****o
发帖数: 89
16
OMP比thread抽象层次高,能有就用。
如果用pthread,你就得自己控制有多少个threads.
而且OMP提供许多collective操作,比pthreads好用多了
l******9
发帖数: 579
17
Hi,
I am trying to do parallelization for a computing intensive problem.
I am working on a Linux cluster where each node is a multicore processor.
e.g. 2 or 4 quad-core processor per node.
I want to reduce latency and improve performance as much as possible.
I plan to use multiprocessing and multithreading at the same.
Each process run on a distinct node and each process spawn many threads
on each node. This is a 2 level parallelism.
For multiprocessing, I would like to choose MPI.
For multithre... 阅读全帖
l******9
发帖数: 579
18
Hi,
I am trying to do parallelization for a computing intensive problem.
I am working on a Linux cluster where each node is a multicore processor.
e.g. 2 or 4 quad-core processor per node.
I want to reduce latency and improve performance as much as possible.
I plan to use multiprocessing and multithreading at the same.
Each process run on a distinct node and each process spawn many threads
on each node. This is a 2 level parallelism.
For multiprocessing, I would like to choose MPI.
For multithre... 阅读全帖
c********r
发帖数: 286
19
Pthread 没有,有一个thread的
public class BlockingQueue {
private List queue = new LinkedList();
private int limit = 10;
public BlockingQueue(int limit){
this.limit = limit;
}
public synchronized void enqueue(Object item) throws InterruptedException{
while(this.queue.size() == this.limit){
wait();
}
if(this.queue.isEmpty()){
notifyAll();
}

this.queue.add(item);
}
public synchronized Object dequeue() throws InterruptedException {
while(this.queue.isEmpty... 阅读全帖
t****s
发帖数: 141
20
来自主题: Java版 - [转载] RH9 and PThread
【 以下文字转载自 Linux 讨论区 】
【 原文由 thomas 所发表 】
Hey, anyone have tried pthread under RH9 espeically with Java?
p******g
发帖数: 347
21
Check out the CountdownLatch in Java. it's just what you needed, and it's
fairly easy to implement it with pthread semaphore or what ever
synchronization stuff. CyclicBarrier works for you, too.

同步
tL2a
i**p
发帖数: 902
22
来自主题: Programming版 - pthread and C++
Can we program multi-thread code with pthread library?
k***r
发帖数: 4260
23
来自主题: Programming版 - Pthread support on Windows XP
i have no experience with it but it looks like you could
just link with the DLL, include the header files and run?

pthreads-
F******8
发帖数: 51
24
来自主题: Programming版 - DJGPP下怎样用pthread.h?
我在Windows XP下装了DJGPP C++ Compiler,想试一下multithread。
可是编译通不过。各位大侠, 请指教该下载安装那个library。在DJGPP上,
有个link到fsu.edu的连接,下载pthread.zip。可是连接断了。
不知道在哪里可以找到。多谢多谢。
j*a
发帖数: 14423
25
来自主题: Programming版 - DJGPP下怎样用pthread.h?
可能是这个?
http://moss.csc.ncsu.edu/~mueller/pthreads/
O*******d
发帖数: 20343
26
来自主题: Programming版 - 弱问一句关于pthread的
你要给linker加上pthread的库。
g****y
发帖数: 436
27
来自主题: Programming版 - pthread in cygwin
sorry, no chinese input here.
I wrote an c app in ubuntu with pthread libs linked and it takes about 1m to
finish.
Then I compiled the same c app in cygwin using the same gcc flags and it
passed.
HOwever, the resulting c app takes around 10 ms to finish.
After revieweing the logs, I found that threads spent too much time waiting
for the working thread accessing mutexs.
In one sentence, the working thread becomes much slower in cygwin.
COuld any one help me with this?
t****t
发帖数: 6806
28
for t1 and t2 waiting each other, use pthread_barrier_t. see pthread
document.

同步
tL2a
A**u
发帖数: 2458
29
来自主题: Programming版 - 请教pthread producer-consumer问题
照书编了一个,
结果总是不对,请大牛看看问题出在哪里呢
#include
#include
#include
pthread_mutex_t region_mutex = PTHREAD_MUTEX_INITIALIZER;
sem_t items;
int b; /* buffer size = 1; */
void add_buffer(int i){
b = i;
}
int get_buffer(){
return b ;
}
void *producer(void*)
{
int i = 0;
std::cout <<"I'm a producer" << std::endl;
while (1) {
pthread_mutex_lock(®ion_mutex);
add_buffer(i);
pthread_mutex_unlock(®ion_mutex);
sem_post(&ite... 阅读全帖
A**u
发帖数: 2458
30
来自主题: Programming版 - 请教pthread producer-consumer问题
我又测试了下面的例子
#include
#include
#include
#include
#include
using std::cout;
using std::endl;
sem_t sem;
void* fun(void*){
while( true ){
sem_wait(&sem);
cout << "Hello " << endl;
}
return 0;
}
int main(){
pthread_t ID;
int res = sem_init(&sem,1,0);
if (res == -1)
{
cout << "sem failed" << endl;
cout << errno << endl;
return 0;
}
pthread_create(&ID... 阅读全帖
M**********n
发帖数: 432
31
来自主题: Programming版 - 请教pthread producer-consumer问题
try to recompile with g++ t.cpp -lrt or -pthread
y****e
发帖数: 23939
32
来自主题: Programming版 - pthread on windows?
请教一下windows support pthread 吗?我用的compiler是vc++ 2008。
a***e
发帖数: 1140
33
来自主题: Programming版 - pthread on windows?
我用过pthread 2.8 for windows,so far it works.
O*******d
发帖数: 20343
34
来自主题: Programming版 - pthread on windows?
The answer is Yes.
你需要下载pthread的库,
O*******d
发帖数: 20343
35
来自主题: Programming版 - pthread on windows?
运行时需要pthread的dll
Y**G
发帖数: 1089
36
来自主题: Programming版 - gcc编译选项 -lpthread vs -pthread
-lpthread比较容易理解,就是连接libpthread库。后来试了一下,改成-pthread好像
也行,不知是为什么,请问有知道的可以解释一下吗?
Y**G
发帖数: 1089
37
来自主题: Programming版 - gcc编译选项 -lpthread vs -pthread
看来用

看来用-pthread兼容新性比较好
O****C
发帖数: 368
38
来自主题: Software版 - Mac Air上的OneNote突然不能用了
完全不能打开。
我已经重装几次都不行。麻烦你们帮我看看error report。 谢谢。
Microsoft Error Reporting log version: 2.0
Error Signature:
Exception: EXC_BAD_ACCESS
Date/Time: 2014-09-10 22:55:06 +0000
Application Name: Microsoft OneNote
Application Bundle ID: com.microsoft.onenote.mac
Application Signature: ONMC
Application Version: 15.2.140713
Crashed Module Name: MicrosoftOffice
Crashed Module Version: 15.2.140713
Crashed Module Offset: 0x00071f94
Blame Module Name: MicrosoftOffice
Blame Module Version: 15.2.140713
Blame Modu... 阅读全帖
r**u
发帖数: 1567
39
来自主题: JobHunting版 - bloomberg 面经 - 挂面了
我的面经:
(1)简单说了一下research
(2) do u you multi-threading? Yes. I use openMP and pthread.
(3) how do you synchronize with pthread? pthread has mutex and conditional
variable.
(4) when to use conditional variable? (never use it and forget the concept)
"when waiting for some condition to happen" (这不费话么)
(5) you have a functions A and B, both will request resource x and y, what
could happen?
deadlock.
(6) how to avoid it? "f***, how would i know" (use reentry mutex: wrong...)
在很多提示之后,终于明白
w****g
发帖数: 597
40
在我运行命令‘man pthread_create’,就得到系统没有online manual的回应。原因
就是我的Ubuntu9.04 desktop还没有安装相应的manual package. 请问如何安装这些安
装包可以浏览online mannual. 例如,
$ man pthread_create
No manual entry for pthread_create
我在Synaptic Package Manager中用pthread搜索,也没有找到pthread的online
manual.
请问如何在Ububtu9.04安装pthread的online manual?
n******t
发帖数: 4406
41
来自主题: Programming版 - (zz)C++11新特性
我觉得这种invention是没边的。。什么功能都想弄出来,最后就是杂和乱。当然我最近
很长一段时间可能做系统开发比较多,看法不一定全面。
variadic template貌似是从C99里面抄过来的? 而且其实C99里面加的新功能其实比起C
++来说保守太多了,而且都是放到标准里面有不少需求的特性,结果其实际上大部分稍
微考虑一点移植性的程序都不太用C99的新功能。
至于thread,跨平台的idea固然是没有问题的,但是就这个case来说,在C++里面弄出这
么一个内建的功能,比起调用pthread库来说,有什么好处?我的感觉除了麻烦,没有好
处。移植性?pthread在所有UNIX和Windows上都有实现,而等到C11在所有平台上都有良
好支持恐怕更慢。C++的thread有pthread不能完成的事情么,就我所知没有,反过来呢
?一定是有的。加入这么个东西,首先不支持C11的编译器就出问题了,如果还没有别的
好处,程序员为什么要用?
我个人的感觉编程打字不是瓶颈,也就是说,如果一个功能推出只是为了少打几个字,
意义不是很大。当然有些时候,简化了句法,同时也简化了思路。但是对于... 阅读全帖
n******t
发帖数: 4406
42
来自主题: Programming版 - (zz)C++11新特性
我觉得这种invention是没边的。。什么功能都想弄出来,最后就是杂和乱。当然我最近
很长一段时间可能做系统开发比较多,看法不一定全面。
variadic template貌似是从C99里面抄过来的? 而且其实C99里面加的新功能其实比起C
++来说保守太多了,而且都是放到标准里面有不少需求的特性,结果其实际上大部分稍
微考虑一点移植性的程序都不太用C99的新功能。
至于thread,跨平台的idea固然是没有问题的,但是就这个case来说,在C++里面弄出这
么一个内建的功能,比起调用pthread库来说,有什么好处?我的感觉除了麻烦,没有好
处。移植性?pthread在所有UNIX和Windows上都有实现,而等到C11在所有平台上都有良
好支持恐怕更慢。C++的thread有pthread不能完成的事情么,就我所知没有,反过来呢
?一定是有的。加入这么个东西,首先不支持C11的编译器就出问题了,如果还没有别的
好处,程序员为什么要用?
我个人的感觉编程打字不是瓶颈,也就是说,如果一个功能推出只是为了少打几个字,
意义不是很大。当然有些时候,简化了句法,同时也简化了思路。但是对于... 阅读全帖
d****i
发帖数: 4809
43
来自主题: Programming版 - 请推荐C++开发环境
什么库呢?
No, you can't. Windows has its own threading library which is completely
different from pthread. If you really want to use pthread in Windows, you
need to use Cygwin as a layer of simulation. But after all, Cygwin is just a
dll in Windows environment, which is not true pthread anyway. But using
Cygwin gives you the convenience that same code can be run on both Windows
and Linux without modification. Do remember to use -lpthread flag in your
linker option.
d***j
发帖数: 25
44
来自主题: Unix版 - multithread programming
Now I m multithreading a program.
First I try pthread , ihave included the header files and added compiler switches, but compiler always consider no implementation of the pthread methods, "implicit declaration" is reported.
So i turn to thread methods, this time everything ok. Do we need include sone library of pthread when we use it?What we shall do?
Thanks.
d********n
发帖数: 54
45
来自主题: JobHunting版 - Google面经
本人PhD,3年半工作经验。2个月前收到Google recruiter电话,开始面试,一个月前
拿到offer,然后开始了漫长的谈判,昨天终于签字。上来share一下面经。
2年前面过google,职位不喜欢,把它拒了。因为他们有记录,所以这次只安排了4人面
试。
第一个是老美,先问了一些简单问题,比如怎么判断一个32 bit是big endian 还是
small endian等等。最后出了一道算法题,也很容易,给定K个sorted array,要求输
出一个大的sorted array。简单的merge sort就解决了。不过merge sort 要求每次K个
array中,最小的element。简单的当然是scan这K个array。我提出可以把K个array的当
前element放入Heap structure,这样每次搜索就从O(K)降低到O(logK)。最后写了个程
序。
第二个是老中。也是先问了一些简单问题,然后让我设计一个分布式文件系统,给定
path name,可以读写文件。具体的system design这里就不提了。其中一个细节是,给
定path name,怎么知... 阅读全帖
g**u
发帖数: 583
D*********y
发帖数: 876
47
来自主题: JobHunting版 - 网络公司面经,求祝福
问了很多题
没怎么coding,基本上是讲一下思路
白板上画个图,就过了
这一天我就在不停的擦黑板
几乎没考算法题
求祝福!
谢谢大家
现在记得的面试题有:
简历的每句话都被问到了
一句一句的问,汗
就跟答辩似的,比答辩的时候讲的还细
解释一下research中用过的machine learning算法
有一个项目中做了一个数据库,把数据库结构画出来,解释各个entity之间的关系
join的种类,区别
sql用的是哪种(mysql之类)
difference between struct and class
features of object oriented design
give examples;how did you used OOD in your research
give the definition of the classes used in your research project
virtual function; pure virtual function; abstract class
for base/derived classes,
destruct... 阅读全帖
P**********c
发帖数: 3417
48
来自主题: JobHunting版 - 复习C++ multithreading的书
有推荐吗?最好是用pthread的。advanced Linux Programming是用C写的,感觉挪到C++不是很方便。Thinking in C++里面有一章讲multithreading用的是ZThread, 现在好像没什么人用?有类似style的(在C++ class的framework里面讲,不是C style的)讲pthread的C++的书吗?
a****n
发帖数: 1887
49
来自主题: JobHunting版 - 复习C++ multithreading的书
直接找multithreading 的书看好了,一般都是c code
现在用的比较多的是, windows thread, pthread(pthread 也有windows 版本), 还
有boost thread.
w**********2
发帖数: 20
50
来自主题: JobHunting版 - G家 system design 和 open ended questions
大家好,5天前,hc 送审的时候, 纠结通过率,搜到了这个网站,(这网站在新加坡
貌似没什么人用) 相见恨晚。。 3天前,写了onsite 小面筋,想求个祝福。可惜新注
册的用户,禁言三天,没有发上来。三天后,hc 的结果出来了, 还要加一轮。不管机
率如何, 既然还有希望,准备拼一枪。
“our profile was actually reviewed at our hiring committee in the US this
morning and I just received the results. The committee has actually decided
they need some additional data through a couple more interviews.
Accordingly, I'd like to set up 2 more interviews for you, these interviews
will be focused on system design and open ended questions.”
看了版上... 阅读全帖
1 2 3 4 5 6 7 8 下页 末页 (共8页)