MESSAGE
DATE | 2016-12-21 |
FROM | Ruben Safir
|
SUBJECT | Re: [Learn] Noobdy is home
|
From learn-bounces-at-nylxs.com Wed Dec 21 22:37:22 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 5DDFF161312; Wed, 21 Dec 2016 22:37:22 -0500 (EST) X-Original-To: learn-at-nylxs.com Delivered-To: learn-at-nylxs.com Received: from [10.0.0.62] (flatbush.mrbrklyn.com [10.0.0.62]) by mrbrklyn.com (Postfix) with ESMTP id DFA63160E77; Wed, 21 Dec 2016 22:37:19 -0500 (EST) To: learn-at-nylxs.com References: <20161221222023.241AE2EB50-at-panix3.panix.com> <20161221233753.GA23084-at-www.mrbrklyn.com> <1482374226344.5903-at-liu.edu> <07a86170-7a00-89ba-a23a-21dd5766f305-at-panix.com> From: Ruben Safir Message-ID: Date: Wed, 21 Dec 2016 22:37:19 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <07a86170-7a00-89ba-a23a-21dd5766f305-at-panix.com> Content-Type: multipart/mixed; boundary="------------BE7BE0A44A33F46D100587AE" Subject: Re: [Learn] Noobdy is home 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: , Errors-To: learn-bounces-at-nylxs.com Sender: "Learn"
This is a multi-part message in MIME format. --------------BE7BE0A44A33F46D100587AE Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit
On 12/21/2016 10:10 PM, Ruben Safir wrote: > On 12/21/2016 09:37 PM, Samir Iabbassen wrote: >> did students boycott the final? > > darn if I know. > > The school is empty. The schedule said we had a final in our room. The > room was open with no one there. > > I need your expertise to help find a way to solve this. It's like > dealing with a rubics cube, and this problem must have been solved a > million times. >
I GOT IT!! I didn't ingrate it into the main program but this is the prototype
/* * ===================================================================================== * * Filename: test.cpp * * Description: Threading Experiment * * Version: 1.0 * Created: 12/18/2016 12:46:51 PM * Revision: none * Compiler: gcc * * Author: Ruben Safir (mn), ruben-at-mrbrklyn.com * Company: NYLXS Inc * * ===================================================================================== */
#include #include #include std::mutex medco; std::mutex master;
namespace testing{ std::thread t[10]; class PIC { public: PIC():source_index{&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(); }); std::cerr << i << ": Making a thread" << std::endl; } };
~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 * loc_canvas_index; char * loc_source_index; sync_canvas_and_input(loc_canvas_index, loc_source_index); for( int i = 9; i>=0; i-- ) { *loc_canvas_index = loc_source_index[i]; std::cerr << i << ": Copy " << loc_source_index[i] << std::endl; std::cerr << i << ": Copied to loc_canvas_index " << reinterpret_cast(*loc_canvas_index) << std::endl; loc_canvas_index++; }
}; void sync_canvas_and_input(char * &loc_canvas_index, char * &loc_source_index ) { std::cout << "**LOCKING**" << std::endl; std::lock_guard turn(medco); loc_canvas_index = canvas_index; loc_source_index = source_index; source_index += 10; canvas_index += 10; };
char * get_canvas() { return canvas; } char * get_canvas_index() { return canvas_index; } char * get_source_index() { return source_index; }
private: char * canvas = new char[100]{ 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z' }; char * canvas_index; char source[100] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }; char * source_index; }; }//end namespace
int main(int argc, char** argv) { testing::PIC fido; for(int i = 0; i<100;i++) { std::cout << i << " Canvas Position " << fido.get_canvas()[i] << std::endl; }
return 0; }
>> ________________________________________ >> From: Ruben Safir >> Sent: Wednesday, December 21, 2016 6:37 PM >> To: learn-at-nylxs.com >> Cc: Samir Iabbassen >> Subject: Noobdy is home >> >> I'm at the school and nobdy is here. Rodriguez is giving a final, but >> the 6th floor is emtpy as is the department. >> >> >> -- >> 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 >> > >
-- 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
--------------BE7BE0A44A33F46D100587AE Content-Type: text/plain; charset=UTF-8; name="makefile" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="makefile"
tesitng : g++ -Wall -pthread -ggdb ./test.cpp
--------------BE7BE0A44A33F46D100587AE Content-Type: text/x-c++src; name="test.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="test.cpp"
/* * ===================================================================================== * * Filename: test.cpp * * Description: Threading Experiment * * Version: 1.0 * Created: 12/18/2016 12:46:51 PM * Revision: none * Compiler: gcc * * Author: Ruben Safir (mn), ruben-at-mrbrklyn.com * Company: NYLXS Inc * * ===================================================================================== */
#include #include #include std::mutex medco; std::mutex master;
namespace testing{ std::thread t[10]; class PIC { public: PIC():source_index{&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(); }); std::cerr << i << ": Making a thread" << std::endl; } };
~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 * loc_canvas_index; char * loc_source_index; sync_canvas_and_input(loc_canvas_index, loc_source_index); for( int i = 9; i>=0; i-- ) { *loc_canvas_index = loc_source_index[i]; std::cerr << i << ": Copy " << loc_source_index[i] << std::endl; std::cerr << i << ": Copied to loc_canvas_index " << reinterpret_cast(*loc_canvas_index) << std::endl; loc_canvas_index++; }
}; void sync_canvas_and_input(char * &loc_canvas_index, char * &loc_source_index ) { std::cout << "**LOCKING**" << std::endl; std::lock_guard turn(medco); loc_canvas_index = canvas_index; loc_source_index = source_index; source_index += 10; canvas_index += 10; };
char * get_canvas() { return canvas; } char * get_canvas_index() { return canvas_index; } char * get_source_index() { return source_index; }
private: char * canvas = new char[100]{ 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z', 'z', 'z','z','z','z','z','z','z','z','z' }; char * canvas_index; char source[100] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' }; char * source_index; }; }//end namespace
int main(int argc, char** argv) { testing::PIC fido; for(int i = 0; i<100;i++) { std::cout << i << " Canvas Position " << fido.get_canvas()[i] << std::endl; }
return 0; }
--------------BE7BE0A44A33F46D100587AE Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Learn mailing list Learn-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/learn
--------------BE7BE0A44A33F46D100587AE--
|
|