WAITING ON MORE THAN 64 HANDLES

Similar documents
TARGET IMPACT DETECTION ALGORITHM USING COMPUTER-AIDED DESIGN (CAD) MODEL GEOMETRY

AVOIDING GIMBAL LOCK IN A TRAJECTORY SIMULATION

COMPUTATIONAL FLUID DYNAMICS (CFD) ANALYSIS AND DEVELOPMENT OF HALON- REPLACEMENT FIRE EXTINGUISHING SYSTEMS (PHASE II)

DoD Common Access Card Information Brief. Smart Card Project Managers Group

Multi-Modal Communication

Android: Call C Functions with the Native Development Kit (NDK)

Approaches to Improving Transmon Qubits

FUDSChem. Brian Jordan With the assistance of Deb Walker. Formerly Used Defense Site Chemistry Database. USACE-Albuquerque District.

Service Level Agreements: An Approach to Software Lifecycle Management. CDR Leonard Gaines Naval Supply Systems Command 29 January 2003

NATO-IST-124 Experimentation Instructions

Accuracy of Computed Water Surface Profiles

AFRL-ML-WP-TM

4. Lessons Learned in Introducing MBSE: 2009 to 2012

David W. Hyde US Army Engineer Waterways Experiment Station Vicksburg, Mississippi ABSTRACT

Dana Sinno MIT Lincoln Laboratory 244 Wood Street Lexington, MA phone:

ARINC653 AADL Annex Update

Empirically Based Analysis: The DDoS Case

HEC-FFA Flood Frequency Analysis

Vision Protection Army Technology Objective (ATO) Overview for GVSET VIP Day. Sensors from Laser Weapons Date: 17 Jul 09 UNCLASSIFIED

Creating, Positioning, and Rotating Rectangles Using C++

Using Model-Theoretic Invariants for Semantic Integration. Michael Gruninger NIST / Institute for Systems Research University of Maryland

Kathleen Fisher Program Manager, Information Innovation Office

Uniform Tests of File Converters Using Unit Cubes

Army Research Laboratory

Running CyberCIEGE on Linux without Windows

Apparel Research Network Upgrade Special Measurement Electronic Order File Final Technical Report September 27, 2004

U.S. Army Research, Development and Engineering Command (IDAS) Briefer: Jason Morse ARMED Team Leader Ground System Survivability, TARDEC

Space and Missile Systems Center

2013 US State of Cybercrime Survey

ARL Eye Safer Fiber Laser Testbed LabView Automation and Control

Architecting for Resiliency Army s Common Operating Environment (COE) SERC

ASSESSMENT OF A BAYESIAN MODEL AND TEST VALIDATION METHOD

Edwards Air Force Base Accelerates Flight Test Data Analysis Using MATLAB and Math Works. John Bourgeois EDWARDS AFB, CA. PRESENTED ON: 10 June 2010

Wireless Connectivity of Swarms in Presence of Obstacles

Information, Decision, & Complex Networks AFOSR/RTC Overview

ENHANCED FRAGMENTATION MODELING

Defense Hotline Allegations Concerning Contractor-Invoiced Travel for U.S. Army Corps of Engineers' Contracts W912DY-10-D-0014 and W912DY-10-D-0024

Instructions for Installing digibase Plug-in on a Terra Harvest Controller

Web Site update. 21st HCAT Program Review Toronto, September 26, Keith Legg

ENVIRONMENTAL MANAGEMENT SYSTEM WEB SITE (EMSWeb)

High-Assurance Security/Safety on HPEC Systems: an Oxymoron?

Washington University

TrafficGen Architecture Document

75th Air Base Wing. Effective Data Stewarding Measures in Support of EESOH-MIS

REPORT DOCUMENTATION PAGE

MATREX Run Time Interface (RTI) DoD M&S Conference 10 March 2008

Technological Advances In Emergency Management

MODELING AND SIMULATION OF LIQUID MOLDING PROCESSES. Pavel Simacek Center for Composite Materials University of Delaware

Setting the Standard for Real-Time Digital Signal Processing Pentek Seminar Series. Digital IF Standardization

Directed Energy Using High-Power Microwave Technology

A Review of the 2007 Air Force Inaugural Sustainability Report

Laboratory Assessment of Commercially Available Ultrasonic Rangefinders

Concept of Operations Discussion Summary

Towards a Formal Pedigree Ontology for Level-One Sensor Fusion

A Practical Application of the Computational Science Environment (CSE)

Use of the Polarized Radiance Distribution Camera System in the RADYO Program

Shallow Ocean Bottom BRDF Prediction, Modeling, and Inversion via Simulation with Surface/Volume Data Derived from X-Ray Tomography

SURVIVABILITY ENHANCED RUN-FLAT

Monte Carlo Techniques for Estimating Power in Aircraft T&E Tests. Todd Remund Dr. William Kitto EDWARDS AFB, CA. July 2011

CENTER FOR ADVANCED ENERGY SYSTEM Rutgers University. Field Management for Industrial Assessment Centers Appointed By USDOE

Distributed Real-Time Embedded Video Processing

Col Jaap de Die Chairman Steering Committee CEPA-11. NMSG, October

Space and Missile Systems Center

Smart Data Selection (SDS) Brief

A Distributed Parallel Processing System for Command and Control Imagery

LARGE AREA, REAL TIME INSPECTION OF ROCKET MOTORS USING A NOVEL HANDHELD ULTRASOUND CAMERA

Basing a Modeling Environment on a General Purpose Theorem Prover

US Army Industry Day Conference Boeing SBIR/STTR Program Overview

Exploring the Query Expansion Methods for Concept Based Representation

Using Templates to Support Crisis Action Mission Planning

DoD M&S Project: Standardized Documentation for Verification, Validation, and Accreditation

UMass at TREC 2006: Enterprise Track

ATCCIS Replication Mechanism (ARM)

32nd Annual Precise Time and Time Interval (PTTI) Meeting. Ed Butterline Symmetricom San Jose, CA, USA. Abstract

Analysis of the Pan-Tilt-Zoom Consistency of a Sony SNC-RZ30N Camera

Open Systems Development Initiative (OSDI) Open Systems Project Engineering Conference (OSPEC) FY 98 Status Review 29 April - 1 May 1998

Use of Modal Analysis and Surrogate Solution Surfaces to Analyze and Assess Adaptive Autonomous Systems

Corrosion Prevention and Control Database. Bob Barbin 07 February 2011 ASETSDefense 2011

Data Warehousing. HCAT Program Review Park City, UT July Keith Legg,

REPORT DOCUMENTATION PAGE

Fall 2014 SEI Research Review Verifying Evolving Software

An Update on CORBA Performance for HPEC Algorithms. Bill Beckwith Objective Interface Systems, Inc.

Energy Security: A Global Challenge

Office of Global Maritime Situational Awareness

Lessons Learned in Adapting a Software System to a Micro Computer

CALCULATION OF WEAPON PLATFORM ATTITUDE AND CANT USING AVAILABLE SENSOR FEEDBACK

DEVELOPMENT OF A NOVEL MICROWAVE RADAR SYSTEM USING ANGULAR CORRELATION FOR THE DETECTION OF BURIED OBJECTS IN SANDY SOILS

SCICEX Data Stewardship: FY2012 Report

Hand Gesture Data Collection Procedure Using a Myo Armband for Machine Learning

Computer Aided Munitions Storage Planning

Topology Control from Bottom to Top

NEW FINITE ELEMENT / MULTIBODY SYSTEM ALGORITHM FOR MODELING FLEXIBLE TRACKED VEHICLES

The C2 Workstation and Data Replication over Disadvantaged Tactical Communication Links

An Efficient Architecture for Ultra Long FFTs in FPGAs and ASICs

73rd MORSS CD Cover Page UNCLASSIFIED DISCLOSURE FORM CD Presentation

C2-Simulation Interoperability in NATO

73rd MORSS CD Cover Page UNCLASSIFIED DISCLOSURE FORM CD Presentation

Application of Hydrodynamics and Dynamics Models for Efficient Operation of Modular Mini-AUVs in Shallow and Very-Shallow Waters

Cyber Threat Prioritization

SINOVIA An open approach for heterogeneous ISR systems inter-operability

Transcription:

AD AD-E403 690 Technical Report ARWSE-TR-14027 WAITING ON MORE THAN 64 HANDLES Tom Nealis October 2015 U.S. ARMY ARMAMENT RESEARCH, DEVELOPMENT AND ENGINEERING CENTER Weapons and Software Engineering Center Picatinny Arsenal, New Jersey

The views, opinions, and/or findings contained in this report are those of the author(s) and should not be construed as an official Department of the Army position, policy, or decision, unless so designated by other documentation. The citation in this report of the names of commercial firms or commercially available products or services does not constitute official endorsement by or approval of the U.S. Government. Destroy this report when no longer needed by any method that will prevent disclosure of its contents or reconstruction of the document. Do not return to the originator.

REPORT DOCUMENTATION PAGE Form Approved OMB No. 0704-01-0188 The public reporting burden for this collection of information is estimated to average 1 hour per response, including the time for reviewing instructions, searching existing data sources, gathering and maintaining the data needed, and completing and reviewing the collection of information. Send comments regarding this burden estimate or any other aspect of this collection of information, including suggestions for reducing the burden to Department of Defense, Washington Headquarters Services Directorate for Information Operations and Reports (0704-0188), 1215 Jefferson Davis Highway, Suite 1204, Arlington, VA 22202-4302. Respondents should be aware that notwithstanding any other provision of law, no person shall be subject to any penalty for failing to comply with a collection of information if it does not display a currently valid OMB control number. PLEASE DO NOT RETURN YOUR FORM TO THE ABOVE ADDRESS. 1. REPORT DATE (DD-MM-YYYY) October 2015 4. TITLE AND SUBTITLE 2. REPORT TYPE Final 3. DATES COVERED (From To) 5a. CONTRACT NUMBER WAITING ON MORE THAN 64 HANDLES 5b. GRANT NUMBER 5c. PROGRAM ELEMENT NUMBER 6. AUTHORS Tom Nealis 5d. PROJECT NUMBER 5e. TASK NUMBER 5f. WORK UNIT NUMBER 7. PERFORMING ORGANIZATION NAME(S) AND ADDRESS(ES) U.S. Army ARDEC, WSEC Fire Control Systems & Technology Directorate (RDAR-WSF-M) Picatinny Arsenal, NJ 07806-5000 9. SPONSORING/MONITORING AGENCY NAME(S) AND ADDRESS(ES) U.S. Army ARDEC, ESIC Knowledge & Process Management (RDAR-EIK) Picatinny Arsenal, NJ 07806-5000 12. DISTRIBUTION/AVAILABILITY STATEMENT 8. PERFORMING ORGANIZATION REPORT NUMBER 10. SPONSOR/MONITOR S ACRONYM(S) 11. SPONSOR/MONITOR S REPORT NUMBER(S) Technical Report ARWSE-TR-14027 13. SUPPLEMENTARY NOTES 14. ABSTRACT It s often necessary for a Windows based program to wait on a handle to a thread or some other resource during its execution. Occasionally, it s necessary for a program to wait on many handles at one time. If the number of handles exceeds MAXIMUM_WAIT_OBJECTS, which is currently defined as 64, then some extra code must be written to deal with this. 15. SUBJECT TERMS Handle MAXIMUM_WAIT_OBJECTS WaitForMultipleObjects 16. SECURITY CLASSIFICATION OF: 17. LIMITATION OF ABSTRACT a. REPORT U b. ABSTRACT U c. THIS PAGE U SAR 18. NUMBER OF PAGES 7 19a. NAME OF RESPONSIBLE PERSON Tom Nealis 19b. TELEPHONE NUMBER (Include area code) (973) 724-8048 Standard Form 298 (Rev. 8/98) Prescribed by ANSI Std. Z39.18

CONTENTS Page Introduction 1 Methodology 1 Conclusions 2 Distribution List 3 i

INTRODUCTION The need to wait on more than 64 handles was first encountered while upgrading some old software to run more efficiently by breaking down tasks to run in multiple worker threads. Almost 200 threads were spawned and then it was found that there was a maximum number of handles that could be waited on. The maximum was set by a global definition of MAXIMUM_WAIT_OBJECTS, which equals 64. All of the threads/tasks needed to be completed first in order to report the completion of the process to the calling function. METHODOLOGY The initial situation presented was having all of the handles to the threads inside a std::vector. The general idea to handle this situation was to break down the number of thread handles into 64 or less chunks and spawn a subsequent thread for each group. That thread would then wait on the 64 thread handles of that group. Then, one would wait on all the handles produced by spawning a thread for each group. The following sequence is the block of code/algorithm that was created for the situation of having more than 64 handles: std::vector<handle> new_handles; int threads_needed = FCT_Threads.size() / MAXIMUM_WAIT_OBJECTS; threads_needed += ((FCT_Threads.size() % MAXIMUM_WAIT_OBJECTS) == 0)? 0 : 1; for(int i = 0; i < threads_needed; ++i) { WaitThreadData* data = new WaitThreadData; if((i + 1) < threads_needed) { data->quantity = MAXIMUM_WAIT_OBJECTS; memcpy_s(data->handles, sizeof(handle) * MAXIMUM_WAIT_OBJECTS, &FCT_Threads[i * MAXIMUM_WAIT_OBJECTS], sizeof(handle) * MAXIMUM_WAIT_OBJECTS); } else { //partial group data->quantity = FCT_Threads.size() % MAXIMUM_WAIT_OBJECTS; memcpy_s(data->handles, sizeof(handle) * data->quantity, &FCT_Threads[i * MAXIMUM_WAIT_OBJECTS], sizeof(handle) * data- >quantity); } } HANDLE ct = CreateThread(NULL, 0, CFCT_GenDlg::WaitThreads, (LPVOID)data, 0, NULL); new_handles.push_back(ct); unsigned long ret = WaitForMultipleObjects(new_handles.size(), new_handles.data(), true, INFINITE); The first step the code takes is to figure out how many threads need to spawn. This is achieved by dividing by the maximum wait objects and then checking for a remainder. If there is a remainder, then an additional thread will be needed for the partial group. The next step is to iterate once for the number of threads needed, filling the parameter struct appropriately. The parameter stuct is comprised of an array of handles with a maximum size of MAX_WAIT_OBJECTS and an integer holding the total quantity. Once all the waitthreads are created, a final wait is initiated on the current thread with the handles of all the created waitthreads. Upon return, all the threads would have completed running their tasks and can be cleaned up. 1

CONCLUSIONS This code snippet is not the silver bullet for all problems associated with waiting on more than 64 handles. It will, however, work for up to 4,096 generated threads. It does give a very good starting point for anyone dealing with a similar issue. 2

DISTRIBUTION LIST U.S. Army ARDEC ATTN: RDAR-EIK RDAR-WSF-M, T. Nealis Picatinny Arsenal, NJ 07806-5000 Defense Technical Information Center (DTIC) ATTN: Accessions Division 8725 John J. Kingman Road, Ste 0944 Fort Belvoir, VA 22060-6218 GIDEP Operations Center P.O. Box 8000 Corona, CA 91718-8000 gidep@gidep.org 3

Patricia Alameda Patricia Alameda Andrew Pskowski 4