Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Kenneth Carter

Pages: [1]
1
I am not sure if I understand the unique_lock very well. I have this scenerio with the MT algorithm.

I have determined that there is no gain to the algorithm if the generate method has to initialize the threads every time before twisting the array[ 624 ].

I am taking an approach were the contructor creates the threads at the time that the CRandomMT is instantiated. I assign a block of the array to each thread. then I want each thread to stay running for the lifetime of the CRandomMT random number generator. I also want the threads to wait until I queue them to twist there block of the array. then once they are done wait again until they are queued to do it again.

each block of the array is isolated from another block of the array.

does a unique_lock provide this functionality or does it behave differently?

Kenneth

2
I am exploring the Mersenne twister algorithym implementing it is a parallel algorithym. I need to pass some pointers into the thread and I was wondering which header contains std::ref ?

Kenneth

3
Error   4   
error C2558: class 'std::thread' : no copy constructor available or copy constructor is declared 'explicit'
f:\program files (x86)\microsoft visual studio 9.0\vc\include\vector   line 1211

I recently aquired your book and was reading through. and I tried using a std::vector with the just::thread class.

Kenneth

4
General Discussion about just::thread / unresolved external symbol
« on: November 20, 2008, 07:25:46 PM »
Error   1   
error LNK2019: unresolved external symbol "public: void * __thiscall std::thread::native_handle(void)"
(?native_handle@thread@std@@QAEPAXXZ)
referenced in function "public: __thiscall CParallel::CParallel(void)" (??0CParallel@@QAE@XZ)

I was building a constructor that isolates the threads to a specific cpu core.

then recieved the above error while linking


5
based on the documentation you mentioned that this should return the number of processors.

so I was expecting it to return '2'. I was surprised to recieve the number '2036182'.

which leads to the question of how that number was picked and why?

Kenneth

6
General Discussion about just::thread / break error on t.join()
« on: November 19, 2008, 07:35:22 PM »
// this project was created using VS 2008 C++ win32 console application, with pre-compiled header checked.

this was happening with _JUST_THREAD_DEADLOCK_CHECK being defined in the _preprocessor in properties

I was trying to run the test to verify it was installed and working.

the output of this has been the following:

"hello from the main thread"

nothing else. either the thread is being deadlocked or something is happening that I am not aware of.


// Parallel_1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <thread>
#include <mutex>

std::mutex io_mutex;

void greeting(const char* message)
{
    std::lock_guard<std::mutex> lk(io_mutex);
    std::cout << message << std::endl;
}



int _tmain(int argc, _TCHAR* argv[])
{
    std::thread t( greeting, "hello from another thread" );
    greeting("hello from the main thread");
   
    t.join(); //<-- this is where an error is occuring
    return 0;
}


here is the call stack:

>   msvcr90d.dll!_NMSG_WRITE(int rterrnum=10)  Line 198   C
    msvcr90d.dll!abort()  Line 59 + 0x7 bytes   C
    msvcr90d.dll!terminate()  Line 130   C++
    Parallel.exe!__jss::stack_trace::build_trace_from()  + 0x40 bytes   
    Parallel.exe!__jss::stack_trace::stack_trace()  + 0x42 bytes   
    Parallel.exe!__jss::mutex::lock()  + 0x2e bytes   
    Parallel.exe!std::unique_lock<std::mutex>::unique_lock<std::mutex>(std::mutex & m_={...})  Line 261   C++
    Parallel.exe!CLock::CLock(std::mutex & _m={...})  Line 19 + 0xf bytes   C++
    Parallel.exe!greeting(const char * message=0x010daab0)  Line 16 + 0xd bytes   C++
    Parallel.exe!__jss::__invoke1<void,void (__cdecl*)(char const *),char const *>::operator()(void (const char *)* & __func=0x010c177b, const char * & __a1=0x010daab0)  Line 15 + 0xf bytes   C++
    Parallel.exe!__jss::__invoker1<void,void (__cdecl*)(char const *),char const *>::operator()()  Line 79   C++
    Parallel.exe!__jss::thread_data<__jss::__invoker1<void,void (__cdecl*)(char const *),char const *> >::run()  Line 94   C++
    Parallel.exe!std::`anonymous namespace'::thread_start_function()  + 0x50 bytes   
    msvcr90d.dll!_callthreadstartex()  Line 348 + 0xf bytes   C
    msvcr90d.dll!_threadstartex(void * ptd=0x000e53e0)  Line 331   C
    kernel32.dll!7566e3f3()    
    [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]   
    ntdll.dll!7708cfed()    
    ntdll.dll!7708d1ff()    

7
General Discussion about just::thread / Beta 0.3 build errors
« on: November 19, 2008, 06:13:04 AM »
I followed the instructions for adding the include and lib to my path.

I created a console application x86. I then added the header <thread> and <mutex>

I had 6 build errors and 4 warnings.

Warning   1   
warning C4003: not enough actual parameters for macro 'min'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   282   Parallel
Warning   2   
warning C4003: not enough actual parameters for macro 'max'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   291   Parallel
Error   3   
error C2589: '(' : illegal token on right side of '::'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   291   Parallel
Error   4   
error C2059: syntax error : '::'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   291   Parallel
Warning   5   
warning C4003: not enough actual parameters for macro 'max'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   300   Parallel
Error   6   
error C2589: '(' : illegal token on right side of '::'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   300   Parallel
Error   7   
error C2059: syntax error : '::'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   300   Parallel
Warning   8   
warning C4003: not enough actual parameters for macro 'max'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   309   Parallel
Error   9   
error C2589: '(' : illegal token on right side of '::'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   309   Parallel
Error   10   
error C2059: syntax error : '::'   
c:\program files (x86)\justsoftwaresolutions\justthread\include\jss\config.hpp   309   Parallel

these errors occured with the <windows.h> header included with it removed I recieved 3 warnings
Warning   1   
warning C4146: unary minus operator applied to unsigned type, result still unsigned   
c:\program files (x86)\justsoftwaresolutions\justthread\include\cstdatomic   106   Parallel
Warning   2   
warning C4146: unary minus operator applied to unsigned type, result still unsigned   
c:\program files (x86)\justsoftwaresolutions\justthread\include\cstdatomic   106   Parallel
Warning   3   
warning C4146: unary minus operator applied to unsigned type, result still unsigned   
c:\program files (x86)\justsoftwaresolutions\justthread\include\cstdatomic   106   Parallel


I would appreciate any advice you may have on how to deal with these errors?

Kenneth

Pages: [1]