Ejemplo n.º 1
0
int release_msg_env(MsgEnv* message)
{
 atomic(ON);
   int return_code = K_release_msg_env(message);
   atomic(OFF);
	return return_code;
}
Ejemplo n.º 2
0
void interrupt_handler(variablesignal){
	// save current_process context
	current_process->State = INTERRUPT;
	NewPCB* Prev_Proc=current_process;

atomic(ON);
	//select i process based on interrupt source
	switch(variablesignal){

	case (SIGALRM) : // i_process_timer;
	current_process = i_process_timer();
	i_process_timer();
	//i_process_timer state is set as executing
	context_switch(current_process,);
	break;

	case (SIGUSR1) : // i_process_kb
	current_process = i_process_kb();
	//i_process_kb state is set as executing
	context_switch(current_process, )
	break;

	case (SIGUSR2) : // i_process_crt;
	current_process = i_process_crt();
	//i_process_crt state is set as executing
	context_switch(current_process, );
	break;

//	case D: // i_process_terminate
	}

atomic(OFF);
}
Ejemplo n.º 3
0
int get_console_chars(MsgEnv* message)
{
	atomic(ON);
   int return_code = K_get_console_chars(message);
   atomic(OFF);
	return return_code;
Ejemplo n.º 4
0
int get_trace_buffers (msg_envelope* msg) {
	int retCode = 0;
	atomic(ON);
	retCode = k_get_trace_buffers(msg);
	atomic(OFF);
	return retCode;
}
Ejemplo n.º 5
0
int release_processor()
{
   atomic(ON);
   int return_code = K_release_processor();
   atomic(OFF);
	return return_code;
}
Ejemplo n.º 6
0
int change_priority(int new_priority, int target_pid)
{
   atomic(ON);
   int return_code = K_change_priority(new_priority, target_pid);
   atomic(OFF);
	return return_code;
}
Ejemplo n.º 7
0
int request_process_status(msg_envelope* env) {
	int retCode = 0;
	atomic(ON); 
	retCode = k_request_process_status(env);
	atomic(OFF);
	return retCode;
}
Ejemplo n.º 8
0
int send_message(int target_pid, MsgEnv* message)
{
   atomic(ON);
   int return_code = K_send(target_pid, message);
   atomic(OFF);
   return return_code;
}
Ejemplo n.º 9
0
int request_process_status(MsgEnv* message)
{
   atomic(ON);
   int return_code = K_request_process_status(message);
   atomic(OFF);	
	return return_code;
}
Ejemplo n.º 10
0
MsgEnv* receive_message()
{
   atomic(ON);
   MsgEnv* tempMSG = K_receive();
	atomic(OFF);
	return tempMSG;
}
Ejemplo n.º 11
0
MsgEnv* request_msg_env()
{
    atomic(ON);
 	MsgEnv* tempMSG = K_request_envelope();
   atomic(OFF);
 	return tempMSG;
}
Ejemplo n.º 12
0
int request_delay ( int time_delay, int wakeup_code, msg_envelope * message_envelope )
{
	int retCode;
	atomic(ON);
	retCode = k_request_delay(time_delay, wakeup_code, message_envelope );
	atomic(OFF);
	return retCode;
}
Ejemplo n.º 13
0
msg_envelope * receive_message()
{
    msg_envelope *temp;
    atomic(ON);
    msg_envelope * msgEnv = k_receive_message();
    atomic(OFF);
    return msgEnv;
}
Ejemplo n.º 14
0
int send_message(int dest_process_id, msg_envelope *msg_envelope)
{
    int retCode = 0;
    atomic(ON);
    retCode = k_send_message(dest_process_id, msg_envelope);
    atomic(OFF);
    return retCode;
}
Ejemplo n.º 15
0
int terminate()
{
	int retCode = 0;	
	atomic(ON);	
	retCode = k_terminate();	
	atomic(OFF);	
	return retCode;
}
Ejemplo n.º 16
0
int release_msg_env(msg_envelope *rel_msg)
{
    int retCode;
    atomic(ON);
    retCode=k_release_msg_env(rel_msg);
    atomic(OFF);
    
    return retCode;
}
Ejemplo n.º 17
0
int get_console_chars(msg_envelope *message_envelope )
{
    int retCode;
    atomic(ON);
    retCode=k_get_console_chars(message_envelope);
    atomic(OFF);
    
    return retCode;
}
Ejemplo n.º 18
0
int release_processor()
{
    int retCode;
    atomic(ON);
    retCode=k_release_processor();
    atomic(OFF);
    
    return retCode;
}
Ejemplo n.º 19
0
msg_envelope *request_msg_env()
{
    msg_envelope *temp;
    atomic(ON);
    temp=k_request_msg_env();
    atomic(OFF);
    
    return temp;
}
Ejemplo n.º 20
0
int change_priority(int new_priority, int target_process_id)
{
    int retCode;
    atomic(ON);
    retCode=k_change_priority(new_priority, target_process_id);
    atomic(OFF);
    
    return retCode;
}
Ejemplo n.º 21
0
void tst_QAtomicIntegerXX::fetchAndStore()
{
    QFETCH(LargeInt, value);
    T newValue = ~T(value);
    QAtomicInteger<T> atomic(value);

    QCOMPARE(atomic.fetchAndStoreRelaxed(newValue), T(value));
    QCOMPARE(atomic.load(), newValue);
    QCOMPARE(atomic.fetchAndStoreRelaxed(value), newValue);
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic.fetchAndStoreAcquire(newValue), T(value));
    QCOMPARE(atomic.load(), newValue);
    QCOMPARE(atomic.fetchAndStoreAcquire(value), newValue);
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic.fetchAndStoreRelease(newValue), T(value));
    QCOMPARE(atomic.loadAcquire(), newValue);
    QCOMPARE(atomic.fetchAndStoreRelease(value), newValue);
    QCOMPARE(atomic.loadAcquire(), T(value));

    QCOMPARE(atomic.fetchAndStoreOrdered(newValue), T(value));
    QCOMPARE(atomic.loadAcquire(), newValue);
    QCOMPARE(atomic.fetchAndStoreOrdered(value), newValue);
    QCOMPARE(atomic.loadAcquire(), T(value));
}
Ejemplo n.º 22
0
int main()
{
	unsigned long atomicValue = 4;
	unsigned long retValue = atomic(&atomicValue, 7);

	A fourAs[4] = {1, 2, 3, 4};

	a.inc();
	a.get();

	ptrA = getNewA();
	ptrA = getNewA();

	ptrA->inc();

	toBSS++;

	/* StackCopy Objekt wird aus lokalem Stack-Frame von getStackCopy in den aktuellen Stack-Frame kopiert */
	/* ab 3 Rückgabewerte erfolgt die Rückgabe über den Stack und nicht mehr über Register */
	/* ab dem 8. Parameter werden diese ebenfalls über den Stack übergeben und nicht mehr ausschließlich über Register */
	const StackCopy& stackCopy = getStackCopy();
	/* Error --> Veränderung eines temporären Objekts ist fehleranfällig und deshalb verboten */
	// StackCopy& stackCopy = getStackCopy();
	const RegCopy& regCopy = getRegCopy();
	int ret4 = return4();
	B b = getB();

	int terminator = 0x1234567;

	return 0;
}
Ejemplo n.º 23
0
			void atomic (AtomicType & sends, T && arg, Args &&... args) {
			
				atomic_perform(sends,std::forward<T>(arg));
				
				atomic(sends,std::forward<Args>(args)...);
			
			}
Ejemplo n.º 24
0
bool Parser::exponent(std::string::iterator& iter, double& val)
{
    double localVal = 0;
    auto localIter = iter;

    // Try to evaluate at least one atomic in the exponent
    if (atomic(localIter, localVal))
    {
        double tempVal;

        // Try to evaluate the exponent of all atomics in the product (linking them)
        try
        {
            while (iter != expr.end() && powerAtomic(localIter, tempVal))
                localVal = pow(localVal, tempVal);
        }
        // Rethrow any exception if there is one
        catch (std::exception& e) { throw e; }

        // If successful, move the original iter and product's temp value to the exponent's value
        val = localVal;
        iter = localIter;
        return true;
    }

    return false;
}
Ejemplo n.º 25
0
void tst_QAtomicIntegerXX::testAndSet3()
{
    QFETCH(LargeInt, value);
    T newValue = ~T(value);
    T oldValue;
    QAtomicInteger<T> atomic(value);

    QVERIFY(atomic.testAndSetRelaxed(value, newValue, oldValue));
    QCOMPARE(atomic.load(), newValue);
    QVERIFY(!atomic.testAndSetRelaxed(value, newValue, oldValue));
    QCOMPARE(oldValue, newValue);
    QVERIFY(atomic.testAndSetRelaxed(newValue, value, oldValue));
    QCOMPARE(atomic.load(), T(value));

    QVERIFY(atomic.testAndSetAcquire(value, newValue, oldValue));
    QCOMPARE(atomic.load(), newValue);
    QVERIFY(!atomic.testAndSetAcquire(value, newValue, oldValue));
    QCOMPARE(oldValue, newValue);
    QVERIFY(atomic.testAndSetAcquire(newValue, value, oldValue));
    QCOMPARE(atomic.load(), T(value));

    QVERIFY(atomic.testAndSetRelease(value, newValue, oldValue));
    QCOMPARE(atomic.loadAcquire(), newValue);
    QVERIFY(!atomic.testAndSetRelease(value, newValue, oldValue));
    QCOMPARE(oldValue, newValue);
    QVERIFY(atomic.testAndSetRelease(newValue, value, oldValue));
    QCOMPARE(atomic.loadAcquire(), T(value));

    QVERIFY(atomic.testAndSetOrdered(value, newValue, oldValue));
    QCOMPARE(atomic.loadAcquire(), newValue);
    QVERIFY(!atomic.testAndSetOrdered(value, newValue, oldValue));
    QCOMPARE(oldValue, newValue);
    QVERIFY(atomic.testAndSetOrdered(newValue, value, oldValue));
    QCOMPARE(atomic.loadAcquire(), T(value));
}
Ejemplo n.º 26
0
static l_mem singlestep (lua_State *L) {
  global_State *g = G(L);
  switch (g->gcstate) {
    case GCSpause: {
      if (!isgenerational(g))
        markroot(g);  /* start a new collection */
      /* in any case, root must be marked */
      lua_assert(!iswhite(obj2gco(g->mainthread))
              && !iswhite(gcvalue(&g->l_registry)));
      g->gcstate = GCSpropagate;
      return GCROOTCOST;
    }
    case GCSpropagate: {
      if (g->gray)
        return propagatemark(g);
      else {  /* no more `gray' objects */
        g->gcstate = GCSatomic;  /* finish mark phase */
        atomic(L);
        return GCATOMICCOST;
      }
    }
    case GCSsweepstring: {
      if (g->sweepstrgc < g->strt.size) {
        sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
        return GCSWEEPCOST;
      }
      else {  /* no more strings to sweep */
        g->sweepgc = &g->finobj;  /* prepare to sweep finalizable objects */
        g->gcstate = GCSsweepudata;
        return 0;
      }
    }
    case GCSsweepudata: {
      if (*g->sweepgc) {
        g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
        return GCSWEEPMAX*GCSWEEPCOST;
      }
      else {
        g->sweepgc = &g->allgc;  /* go to next phase */
        g->gcstate = GCSsweep;
        return GCSWEEPCOST;
      }
    }
    case GCSsweep: {
      if (*g->sweepgc) {
        g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
        return GCSWEEPMAX*GCSWEEPCOST;
      }
      else {
        /* sweep main thread */
        GCObject *mt = obj2gco(g->mainthread);
        sweeplist(L, &mt, 1);
        checkSizes(L);
        g->gcstate = GCSpause;  /* finish collection */
        return GCSWEEPCOST;
      }
    }
    default: lua_assert(0); return 0;
  }
}
Ejemplo n.º 27
0
void tst_QAtomicIntegerXX::assign()
{
    QFETCH(LargeInt, value);

    QAtomicInteger<T> atomic(value);
    QAtomicInteger<T> copy;
    copy = atomic;
    QCOMPARE(copy.load(), atomic.load());

    QAtomicInteger<T> copy2;
    copy2 = atomic;  // operator=(const QAtomicInteger &)
    QCOMPARE(copy2.load(), atomic.load());

    QAtomicInteger<T> copy2bis;
    copy2bis = atomic.load(); // operator=(T)
    QCOMPARE(copy2bis.load(), atomic.load());

    // move
    QAtomicInteger<T> copy3;
    copy3 = qMove(copy);
    QCOMPARE(copy3.load(), atomic.load());

    QAtomicInteger<T> copy4;
    copy4 = qMove(copy2);
    QCOMPARE(copy4.load(), atomic.load());
}
Ejemplo n.º 28
0
void DataStruct::print( QString& out, const QString& indent, const QString& newitem, int level, int maxElemSize) const
{
	if (atomic())
	{
		out.append("'");
		if (maxElemSize >= 0)
		{
			out.append( shortenDebugMessageArgument( value().toString(), maxElemSize));
		}
		else
		{
			out.append( value().toString());
		}
		out.append("'");
	}
	else if (array())
	{
		int ii = 1;
		for (; ii<=m_size; ++ii)
		{
			if (ii>1) out.append( ", ");
			m_data.ref[ ii].print( out, indent, newitem, level+1, maxElemSize);
		}
	}
	else if (indirection())
	{
		// ... unexpanded indirection is ignored
	}
	else if (m_description)
	{
		DataStructDescription::const_iterator di = m_description->begin(), de = m_description->end();
		DataStruct::const_iterator ei = structbegin();
		for (int idx=0; di != de; ++di,++ei)
		{
			if (ei->initialized())
			{
				if (idx++)
				{
					out.append( ";");
					print_newitem( out, indent, newitem, level);
				}

				out.append( di->name);
				if (di->array()) out.append( "[]");
				if (di->attribute())
				{
					out.append( "=");
					out.append( ei->toString( maxElemSize));
				}
				else
				{
					out.append( "{");
					ei->print( out, indent, newitem, level+1, maxElemSize);
					out.append( "}");
				}
			}
		}
	}
}
Ejemplo n.º 29
0
void tst_QAtomicIntegerXX::fetchAndXor()
{
    QFETCH(LargeInt, value);
    QAtomicInteger<T> atomic(value);

    T zero = 0;
    T pattern = T(Q_UINT64_C(0xcccccccccccccccc));
    T minusOne = T(~0);

    QCOMPARE(atomic.fetchAndXorRelaxed(zero), T(value));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorRelaxed(pattern), T(value));
    QCOMPARE(atomic.load(), T(value ^ pattern));
    QCOMPARE(atomic.fetchAndXorRelaxed(pattern), T(value ^ pattern));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorRelaxed(minusOne), T(value));
    QCOMPARE(atomic.load(), T(~value));
    QCOMPARE(atomic.fetchAndXorRelaxed(minusOne), T(~value));
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic.fetchAndXorAcquire(zero), T(value));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorAcquire(pattern), T(value));
    QCOMPARE(atomic.load(), T(value ^ pattern));
    QCOMPARE(atomic.fetchAndXorAcquire(pattern), T(value ^ pattern));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorAcquire(minusOne), T(value));
    QCOMPARE(atomic.load(), T(~value));
    QCOMPARE(atomic.fetchAndXorAcquire(minusOne), T(~value));
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic.fetchAndXorRelease(zero), T(value));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorRelease(pattern), T(value));
    QCOMPARE(atomic.load(), T(value ^ pattern));
    QCOMPARE(atomic.fetchAndXorRelease(pattern), T(value ^ pattern));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorRelease(minusOne), T(value));
    QCOMPARE(atomic.load(), T(~value));
    QCOMPARE(atomic.fetchAndXorRelease(minusOne), T(~value));
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic.fetchAndXorOrdered(zero), T(value));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorOrdered(pattern), T(value));
    QCOMPARE(atomic.load(), T(value ^ pattern));
    QCOMPARE(atomic.fetchAndXorOrdered(pattern), T(value ^ pattern));
    QCOMPARE(atomic.load(), T(value));
    QCOMPARE(atomic.fetchAndXorOrdered(minusOne), T(value));
    QCOMPARE(atomic.load(), T(~value));
    QCOMPARE(atomic.fetchAndXorOrdered(minusOne), T(~value));
    QCOMPARE(atomic.load(), T(value));

    QCOMPARE(atomic ^= zero, T(value));
    QCOMPARE(atomic ^= pattern, T(value ^ pattern));
    QCOMPARE(atomic ^= pattern, T(value));
    QCOMPARE(atomic ^= minusOne, T(~value));
    QCOMPARE(atomic ^= minusOne, T(value));
}
Ejemplo n.º 30
0
void
isetdebugmessages(void)
{
  nialptr     x = apop();
  int         oldstatus = debug_messages_on;

  if (atomic(x) && kind(x) == booltype)
    debug_messages_on = boolval(x);
  else if (atomic(x) && kind(x) == inttype)
    debug_messages_on = intval(x);
  else {
    apush(makefault("?setdebugmessages expects a truth-value"));
    freeup(x);
    return;
  }
  apush(createbool(oldstatus));
}