Пример #1
0
        // Called when the core is done with a bank item
        public void release_item(Core core, Bank bank, Dictionary <int, ItemLock> bank_lock, int id)
        {
#if VM_MULTI_CORE
            core.ASSERT_ERR(!bank.contains(id), CoreErrorType.INVALID_BANK_ID, "Bank item doesn't exist, so can't be released: " + id);
            bank_lock[id].release_use();
#endif
        }
Пример #2
0
        // Used when an instruction wants to request access to a bank item
        // The request will only be granted if the item is available
        public WItem request_item(Core core, Bank bank, Dictionary <int, ItemLock> bank_lock, int id)
        {
            core.ASSERT_ERR(!bank.contains(id), CoreErrorType.INVALID_BANK_ID, "Bank item doesn't exist: " + id);

            // Dealing with multi threading
#if VM_MULTI_CORE
            // First request use of the item
            if (bank_lock[id].request_use(core.state.id))
            {
                core.state.multi_core_state = MultiCoreState.RUNNING;
                return(bank.get_item(id));
            }
            // If we are denied the request, we are in a BLOCKED state
            else
            {
                core.state.multi_core_state = MultiCoreState.BLOCKED;
                return null
            }
#else
            // Dealing with a single thread
            // We don't need to check locks, as it impossible to encounter concurrent locks
            return(bank.get_item(id));
#endif
        }
Пример #3
0
 public T pop()
 {
     core.ASSERT_ERR(empty(), CoreErrorType.STACK_UNDERFLOW, "Stack underflow!");
     return(this.stack[this.sp--]);
 }