MESSAGE
DATE | 2016-12-21 |
FROM | Samir Iabbassen
|
SUBJECT | Re: [Learn] thread concurancy
|
From learn-bounces-at-nylxs.com Wed Dec 21 21:49:07 2016 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www.mrbrklyn.com (www.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id B4A5E161316; Wed, 21 Dec 2016 21:49:07 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from B-EXH-EDGE1.liunet.edu (b-edge1.smtp.liu.edu [148.4.248.206]) by mrbrklyn.com (Postfix) with ESMTP id 1EBC5161312 for ; Wed, 21 Dec 2016 21:49:05 -0500 (EST) Received: from B-EXH-1.liunet.edu (148.4.250.210) by B-EXH-EDGE1.liunet.edu (148.4.248.206) with Microsoft SMTP Server (TLS) id 14.3.210.2; Wed, 21 Dec 2016 21:48:58 -0500 Received: from B-EXH-1.liunet.edu (148.4.250.210) by B-EXH-1.liunet.edu (148.4.250.210) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Wed, 21 Dec 2016 21:49:04 -0500 Received: from B-EXH-1.liunet.edu ([148.4.250.210]) by B-EXH-1.liunet.edu ([148.4.250.210]) with mapi id 15.00.1156.000; Wed, 21 Dec 2016 21:49:04 -0500 From: Samir Iabbassen To: Ruben Safir , "learn-at-nylxs.com" Thread-Topic: thread concurancy Thread-Index: AQHSW8u5J02IBUvu5E2+QXalsHxCkqETQTMP Date: Thu, 22 Dec 2016 02:49:03 +0000 Message-ID: <1482374939422.53063-at-liu.edu> References: <2a2adad8-9115-46f3-f74f-82ea0d132614-at-mrbrklyn.com> In-Reply-To: <2a2adad8-9115-46f3-f74f-82ea0d132614-at-mrbrklyn.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [142.255.88.250] MIME-Version: 1.0 Subject: Re: [Learn] thread concurancy X-BeenThere: learn-at-nylxs.com X-Mailman-Version: 2.1.17 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
Hi Ruben,
if you didn't send the project report, please send it to me along with whatever source code you have so far. the semester is at its end and I need to finalize grading. I know you have spent a lots of time on the project and I will be based on it for your total grading. Send me your resume and I will forward it to the my friend for the dba position, meanwhile follow the instructions for formal application. I also got following this morning from another friend if you are interested. >>Hi guys
>>Do you know any jr. App Dev looking for a gig in city?
>>There is job at DOT although not in IT dept. Computer Associate 2
>>Let me know. I will send job link when active.
>>Regards, Happy Holidays and see you in spring... ________________________________________ From: Ruben Safir Sent: Wednesday, December 21, 2016 3:49 PM To: learn-at-nylxs.com Subject: thread concurancy
[This mail was also posted to comp.lang.c++.]
:(
I don't know. I'm very confused about the behavior of this test program I've been right. I'm trying to move date by worker threads from one blob of memory to another and the debugger is saying that the pointers beg and canvas_index is jumping 10 bytes between this two lines
for(int i = 0; i < 10;i++) { t[i] = std::thread([this]{ readin(beg, canvas_index); });
and I'm not sure why. I lost the concurrency somewhere, but can't seem to figure out what I did wrong
#include #include #include std::mutex medco; std::mutex master;
namespace testing{ std::thread t[10]; class PIC { public: PIC():beg{&source[0]} { canvas_index = canvas; std::cout << "Testing Source" << std::endl; for(int i = 0; i<100; i++) { std::cout << i << " " << source[i] << std::endl ; } for(int i = 0; i < 10;i++) { t[i] = std::thread([this]{ readin(beg, canvas_index); }); std::cerr << i << ": Making a thread" << std::endl; sync_canvas_and_input(); } };
void sync_canvas_and_input() { std::cout << "**LOCKING**" << std::endl; std::lock_guard turn(medco); beg += 10; canvas_index += 10; }
~PIC() { std::cerr << "In the destructor" << std::endl; for(int i=0; i<10; i++) { t[i].join(); std::cerr << i << ": Joining a thread" << std::endl; }
}; void readin(char * start, char * loc_canvas_index) { for( int i = 9; i>=0; i-- ) { *loc_canvas_index = start[i]; std::cerr << i << ": Copy " << start[i] << std::endl; std::cerr << i << ": Copied to loc_canvas_index " << reinterpret_cast(*loc_canvas_index) << std::endl; loc_canvas_index++; }
-- So many immigrant groups have swept through our town that Brooklyn, like Atlantis, reaches mythological proportions in the mind of the world - RI Safir 1998 http://www.mrbrklyn.com
DRM is THEFT - We are the STAKEHOLDERS - RI Safir 2002 http://www.nylxs.com - Leadership Development in Free Software http://www2.mrbrklyn.com/resources - Unpublished Archive http://www.coinhangout.com - coins! http://www.brooklyn-living.com
Being so tracked is for FARM ANIMALS and and extermination camps, but incompatible with living as a free human being. -RI Safir 2013
_______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
|
|