pthread

Pthread conditional signal - not working as expected

匿名 (未验证) 提交于 2019-12-03 03:10:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on a project and trying to use pthread_cond_wait() and pthread_cond_signal() to synchronize two threads. My code looks something like this: pthread_mutex_t lock_it = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t write_it = PTHREAD_COND_INITIALIZER; int main(int argc, char**argv) { pthread_t t_send_segments, t_recv_acks; pthread_create(&t_send_segments, NULL, send_segments, (void*)NULL); pthread_create(&t_recv_acks, NULL, recv_acks, (void*)NULL); pthread_join(t_recv_acks, (void**)NULL); pthread_mutex_destroy(&lock_it); pthread_cond

error: invalid conversion from ‘void*’ to ‘void* (*)(void*)’ - pthreads

匿名 (未验证) 提交于 2019-12-03 03:09:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: anisha@linux-y3pi:~> g++ conditionVarTEST.cpp -Wall conditionVarTEST.cpp: In function ‘int main()’: conditionVarTEST.cpp:33:53: error: invalid conversion from ‘void*’ to ‘void* (*)(void*)’ conditionVarTEST.cpp:33:53: error: initializing argument 3 of ‘int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*)’ conditionVarTEST.cpp:34:53: error: invalid conversion from ‘void*’ to ‘void* (*)(void*)’ conditionVarTEST.cpp:34:53: error: initializing argument 3 of ‘int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)

CMake: add dependency to IMPORTED library

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a vendor supplied library archive which I have imported into my project: add_library( lib_foo STATIC IMPORTED GLOBAL ) set_target_properties( lib_foo PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_LIST_DIR}/vendor/foo.a" ) set_target_properties( lib_foo PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_LIST_DIR}/vendor" ) When I try to link an application using this library, I get undefined reference to 'pthread_atfork' linker errors: /usr/lib/libtcmalloc_minimal.a(libtcmalloc_minimal_internal_la-static_vars.o): In function

how to set CPU affinity of a particular pthread?

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'd like to specify the cpu-affinity of a particular pthread. All the references I've found so far deal with setting the cpu-affinity of a process (pid_t) not a thread (pthread_t). I tried some experiments passing pthread_t's around and as expected they fail. Am I trying to do something impossible? If not, can you send a pointer please? Thanks a million. 回答1: This is a wrapper I've made to make my life easier. Its effect is that the calling thread gets "stuck" to the core with id core_id : // core_id = 0, 1, ... n-1, where n is the system's

OpenSSL and multi-threads

匿名 (未验证) 提交于 2019-12-03 03:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I've been reading about the requirement that if OpenSSL is used in a multi-threaded application, you have to register a thread identification function (and also a mutex creation function) with OpenSSL. On Linux, according to the example provided by OpenSSL, a thread is normally identified by registering a function like this: static unsigned long id_function(void){ return (unsigned long)pthread_self(); } pthread_self() returns a pthread_t, and this works on Linux since pthread_t is just a typedef of unsigned long. On Windows pthreads, FreeBSD

I can't use pthread in window platform

匿名 (未验证) 提交于 2019-12-03 03:04:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: My env is Windows8.1 (64bit) and using Visual Studio 2010. I did put all *.dll files in system32 , SYSWOW64(because I use win8 64bit.) and link location where *.lib file for x64-system with VC 2010. of course, I add additional folder lib forders.. , include folders.. etc.. but when I try compile "pthread-used" project, fatal error has occur. -source #include <pthread.h> #include <stdio.h> int doit_id , trd_id ; pthread_t trd ; void * doit ( void * data ){ doit_id = ( int ) data ; return 0 ; } int main (){ trd_id = pthread_create (&

Simple pthread! C++

匿名 (未验证) 提交于 2019-12-03 02:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have no idea why this doesn't work #include <iostream> #include <pthread.h> using namespace std; void *print_message(){ cout << "Threading\n"; } int main() { pthread_t t1; pthread_create(&t1, NULL, &print_message, NULL); cout << "Hello"; return 0; } The error: [Description, Resource, Path, Location, Type] initializing argument 3 of 'int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*)' threading.cpp threading/src line 24 C/C++ Problem 回答1: You should declare the thread main as: void* print_message(void*) // takes

iOS app crashed due to [UIFeedbackGenerator _autoDeactivate]

匿名 (未验证) 提交于 2019-12-03 02:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I received the following report from Crashlytics. I was not calling [UIFeedbackGenerator _autoDeactivate] myself. Maybe some library was doing that. I have done some research but could not find any useful information. Does anyone know what this crash report means? Thank you! Fatal Exception: NSInternalInconsistencyException Exception raised while auto-deactivating <UISelectionFeedbackGenerator: 0x1c012d7a0: prepared=0> for style 2: force deactivating <UISelectionFeedbackGenerator: 0x1c012d7a0: prepared=0> with style TurnOn which is not

Selector name found in current argument registers: isEqual:

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am looking for some assistance with squashing a bug in an OSX app that i just can't work out. I am getting a logged error of: Selector name found in current argument registers: isEqual: But i can't for the life of me work out where it's coming from as the log is very unhelpful. Also i can't reproduce this on my own test systems, but it seems to be happening quite a lot on some of the beta testers machines. This only seems to happen on 10.9. Here is the log file for the crash: Incident Identifier: 77FAD32D-0316-489E-B898-9C084A4FF48A

How do you query a pthread to see if it is still running?

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In my destructor I want to destroy a thread cleanly. My goal is to wait for a thread to finish executing and THEN destroy the thread. The only thing I found about querying the state of a pthread is pthread_attr_setdetachstate but this only tells you if your thread is: PTHREAD_CREATE_DETACHED PTHREAD_CREATE_JOINABLE Both of those have nothing to do with whether the thread is still running or not. How do you query a pthread to see if it is still running? 回答1: It sounds like you have two questions here: How can I wait until my thread completes?