1 /* Copyright (c) 2008, 2021, Oracle and/or its affiliates. 2 3 This program is free software; you can redistribute it and/or modify 4 it under the terms of the GNU General Public License, version 2.0, 5 as published by the Free Software Foundation. 6 7 This program is also distributed with certain software (including 8 but not limited to OpenSSL) that is licensed under separate terms, 9 as designated in a particular file or component or in included license 10 documentation. The authors of MySQL hereby grant you an additional 11 permission to link the program and your derivative works with the 12 separately licensed software that they have included with MySQL. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License, version 2.0, for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with this program; if not, write to the Free Software 21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ 22 23 #ifndef ndb_mt_hpp 24 #define ndb_mt_hpp 25 26 #include <kernel_types.h> 27 #include <TransporterDefinitions.hpp> 28 29 #define JAM_FILE_ID 275 30 31 32 Uint32 mt_get_instance_count(Uint32 block); 33 34 /* Assign block instances to thread */ 35 void mt_init_thr_map(); 36 void mt_add_thr_map(Uint32 block, Uint32 instance); 37 void mt_finalize_thr_map(); 38 39 void sendlocal(Uint32 self, const struct SignalHeader *s, 40 const Uint32 *data, const Uint32 secPtr[3]); 41 void sendprioa(Uint32 self, const struct SignalHeader *s, 42 const Uint32 *data, const Uint32 secPtr[3]); 43 void senddelay(Uint32 thr_no, const struct SignalHeader*, Uint32 delay); 44 void mt_execSTOP_FOR_CRASH(); 45 46 void mt_getSendBufferLevel(Uint32 self, NodeId node, SB_LevelType &level); 47 Uint32 mt_getSignalsInJBB(Uint32 self); 48 49 SendStatus mt_send_remote(Uint32 self, const SignalHeader *sh, Uint8 prio, 50 const Uint32 *data, NodeId nodeId, 51 const LinearSectionPtr ptr[3]); 52 SendStatus mt_send_remote(Uint32 self, const SignalHeader *sh, Uint8 prio, 53 const Uint32 *data, NodeId nodeId, 54 class SectionSegmentPool *thePool, 55 const SegmentedSectionPtr ptr[3]); 56 57 /** 58 * Lock/unlock pools for long signal section(s) 59 */ 60 void mt_section_lock(); 61 void mt_section_unlock(); 62 63 int mt_checkDoJob(Uint32 receiver_thread_idx); 64 65 /** 66 * Are we (not) multi threaded 67 */ 68 bool NdbIsMultiThreaded(); 69 70 /** 71 * Get list of BlockReferences so that 72 * each thread holding an instance of any block in blocks[] get "covered" 73 * (excluding ownThreadId 74 * 75 * eg. calling it with DBLQH, will return a block-reference to *a* block 76 * in each of the threads that has an DBLQH instance 77 */ 78 Uint32 mt_get_thread_references_for_blocks(const Uint32 blocks[], 79 Uint32 ownThreadId, 80 Uint32 dst[], Uint32 len); 81 82 /** 83 * wakeup thread running block 84 */ 85 void mt_wakeup(class SimulatedBlock*); 86 87 #ifdef VM_TRACE 88 /** 89 * Assert that thread calling this function is "owner" of block instance 90 */ 91 void mt_assert_own_thread(class SimulatedBlock*); 92 #endif 93 94 /** 95 * return list of references running in this thread 96 */ 97 Uint32 98 mt_get_blocklist(class SimulatedBlock*, Uint32 dst[], Uint32 len); 99 100 101 struct ndb_thr_stat 102 { 103 Uint32 thr_no; 104 Uint64 os_tid; 105 const char * name; 106 Uint64 loop_cnt; 107 Uint64 exec_cnt; 108 Uint64 wait_cnt; 109 Uint64 local_sent_prioa; 110 Uint64 local_sent_priob; 111 Uint64 remote_sent_prioa; 112 Uint64 remote_sent_priob; 113 }; 114 115 void 116 mt_get_thr_stat(class SimulatedBlock *, ndb_thr_stat* dst); 117 118 /** 119 * Get TransporterReceiveHandle for a specific trpman instance 120 * Currently used for error insert that block/unblock traffic 121 */ 122 class TransporterReceiveHandle * 123 mt_get_trp_receive_handle(unsigned instance); 124 125 /** 126 * return receiver thread handling a particular node 127 * returned number is indexed from 0 and upwards to #receiver threads 128 * (or MAX_NODES is none) 129 */ 130 Uint32 131 mt_get_recv_thread_idx(NodeId nodeId); 132 133 134 #undef JAM_FILE_ID 135 136 #endif 137