Beispiel #1
0
U0 Kill(CTask *task,Bool wait=TRUE)
{
    I64 i;
    CCPU *c;
    Bool found,old_preempt=Preempt(OFF);
    if (TaskValidate(task)) {
        if (task==sys_winmgr_task)
            found=TRUE;
        else
            found=FALSE;
        for (i=0; i<mp_cnt; i++) {
            c=&cpu_structs[i];
            if (task==c->seth_task)
                found=TRUE;
        }
        if (!found) {
            LBts(&task->task_flags,TASKf_KILL_TASK);
            if (wait) {
                do Yield;
                while (TaskValidate(task) && Bt(&task->task_flags,TASKf_KILL_TASK));
            }
        }
    }
    Preempt(old_preempt);
}
Beispiel #2
0
public U0 PressKeyHelp(CTask *task=NULL)
{
  I64 p1=0,p2=0;
  Bool old_preempt=Preempt(OFF);
  CTask *old_hash=Fs->hash_table;
  if (!task) task=Fs;

//This feat is a burden in code.
//It would be nice to lst key
//cmds for all applications,
//but it makes the code too ugly.
//
task=Fs;

  Fs->hash_table=task->hash_table;
  "Press keys to show handler code.\n"
  "<SHIFT-ESC> to exit.\n"
  "Do not press <CTRL-ALT-keys>.\n";
  while (p1!=CH_ESC && p1!=CH_SHIFT_ESC) {
    GetMsg(&p1,&p2,1<<MSG_KEY_DOWN);
    *key_desc=0;
    key_handler=NULL;
    if (task==Fs)
      PutKey(p1,p2|SCF_KEY_DESC);
    else if (TaskValidate(task)) {
      PostMsg(task,MSG_KEY_DOWN,p1,p2|SCF_KEY_DESC);
      while (!key_handler)
	Yield;
    }
    if (*key_desc)
      E(key_handler,512);
  }
  Fs->hash_table=old_hash;
  Preempt(old_preempt);
}
Beispiel #3
0
CSrvCmd *TaskTextInputQue(CTask *srv,CTask *master,
		     U8 *data,I64 flags)
{
  CSrvCmd *result;
  Bool old_preempt=Preempt(OFF);
  CTask *task;
  if (!data || !TaskValidate(srv) ||
      master && !TaskValidate(master) ||
      srv->popup_task && !Bt(&srv->task_flags,TASKf_FILTER_INPUT)) {
    Preempt(old_preempt);
    return NULL;
  }
  result=ACAlloc(sizeof(CSrvCmd));
  result->master_task=master; //in case somebody cares
  result->cmd_code=SVCT_TEXT_INPUT;
  result->flags=flags;
  result->aux_str=AStrNew(data);

  PushFD;
  task=srv->last_input_filter_task;
  if (Bt(&flags,SVCf_HIGHEST_PRIORITY) || task==srv) {
    if (task!=srv)
      TaskWait(srv);
    task=Spawn(&InputFilterTask,NULL,"Input Filter",,srv);
    Cli;
    task->next_input_filter_task=srv->next_input_filter_task;
    task->last_input_filter_task=srv;
    srv->next_input_filter_task=task;
    task->next_input_filter_task->last_input_filter_task=task;
  } else {
Beispiel #4
0
U0 TimeIns()
{
  I64 start1,end1,start2,end2,overhead_time,test_time;
  I64 reg i,reg temp;
  Bool old_preempt=Preempt(OFF);

  CPURep;

//Measure Loop Overhead
  start1=GetTimeStamp;
  for (i=0;i<SAMPLE_SIZE;i++) {
  }
  end1=GetTimeStamp;
  overhead_time=end1-start1;

//Measure remainder...
  start2=GetTimeStamp;
  for (i=0;i<SAMPLE_SIZE;i++)
     temp=i%0x400;
  end2=GetTimeStamp;
  test_time=end2-start2;
  "Remainder Version #1 Cycles\t: %10.5f\n",
    ToF64(test_time-overhead_time)/SAMPLE_SIZE;

//Measure remainder...
  start2=GetTimeStamp;
  for (i=0;i<SAMPLE_SIZE;i++)
     temp=i&0x3FF;
  end2=GetTimeStamp;
  test_time=end2-start2;
  "Remainder Version #2 Cycles\t: %10.5f\n",
    ToF64(test_time-overhead_time)/SAMPLE_SIZE;

  Preempt(old_preempt);
}
U0 SliderDel(CCtrl *c)
{
  Bool old_preempt=Preempt(OFF);
  QueRem(c);
  Preempt(old_preempt);
  Free(c);
}
wxString UserVariableManager::Replace(const wxString& variable)
{
    wxString package = variable.AfterLast(wxT('#')).BeforeFirst(wxT('.')).MakeLower();
    wxString member  = variable.AfterFirst(wxT('.')).MakeLower();

    wxString path(cSets + m_ActiveSet + _T('/') + package + _T('/'));

    wxString base = m_CfgMan->Read(path + cBase);

    if (base.IsEmpty())
    {
        if (Manager::Get()->GetProjectManager()->IsLoading())
        {
            // a project/workspace is being loaded.
            // no need to bug the user now about global vars.
            // just preempt it; ProjectManager will call Arrogate() when it's done.
            Preempt(variable);
            return variable;
        }
        else
        {
            wxString msg;
            msg.Printf(_("In the currently active set, Code::Blocks does not know\n"
                         "the global compiler variable \"%s\".\n\n"
                         "Please define it."), package.wx_str());
            InfoWindow::Display(_("Global Compiler Variables"), msg , 8000, 1000);
            UsrGlblMgrEditDialog d;
            d.AddVar(package);
            PlaceWindow(&d);
            d.ShowModal();
        }
    }

    if (member.IsEmpty() || member.IsSameAs(cBase))
        return base;

    if (member.IsSameAs(cInclude) || member.IsSameAs(cLib) || member.IsSameAs(cObj) || member.IsSameAs(cBin))
    {
        wxString ret = m_CfgMan->Read(path + member);
        if (ret.IsEmpty())
            ret = base + _T('/') + member;
        return ret;
    }

    const wxString wtf(wxT("#$%&???WTF???&%$#"));
    wxString ret = m_CfgMan->Read(path + member, wtf);
    if ( ret.IsSameAs(wtf) )
    {
        wxString msg;
        msg.Printf(_("In the currently active set, Code::Blocks does not know\n"
                     "the member \"%s\" of the global compiler variable \"%s\".\n\n"
                     "Please define it."), member.wx_str(), package.wx_str());
        InfoWindow::Display(_("Global Compiler Variables"), msg , 8000, 1000);
    }

    return ret;
}
CCtrl *SliderNew()
{
  Bool old_preempt;
  CCtrl *c=CAlloc(sizeof(CCtrl));
  c->win_task=Fs;
  c->flags=CTRLF_SHOW|CTRLF_CAPTURE_LEFT_IP;
  c->type=CTRLT_GENERIC;
  c->state=&sld;
  MemSet(&sld,0,sizeof(CSliderState));
  c->draw_it=&DrawSliderCtrl;
  c->left_click=&LeftClickSlider;
  c->update_derived_vals=&UpdateDerivedSliderCtrl;
  old_preempt=Preempt(OFF);
  QueIns(c,Fs->last_ctrl);
  TaskDerivedValsUpdate;
  Preempt(old_preempt);
  return c;
}
Beispiel #8
0
main()
{
    InitConsole();      //Initialize Console
    InitMemMgr();       //Initialize Memory Manager
    InitThreading();    //Initialize Threading

    //CreateThread((unsigned short)RunConsole);
    CreateThread((unsigned short)Thread3);
    CreateThread((unsigned short)Thread3);

    CreateThread((unsigned short)Thread);
    CreateThread((unsigned short)Thread2);
    
    //Create Mutex Semiphore
    holes = CreateSemiphore(64);
    items = CreateSemiphore(0);
    mutex = CreateMutex();

    //[!!!]Must be LAST in main()[!!!]
    Preempt();
    
    //With Preempt() called this should never be executed
    SetError("ERROR! MAIN EXITING! THIS IS IMPOSSIBLE!");
}
U0 MassSpringDemo()
{
  I64 msg_code,p1,p2;
  MyMass *tempm1=NULL,*tempm2=NULL;

  PopUpOk("Left-Click to place mas\n"
	  "Right-Click and drag to\n"
	  "connect with spring.\n\n"
	  "Springs are 100 pixels long.\n");
  SettingsPush; //See $LK,"SettingsPush","MN:SettingsPush"$
  WinMax;

//This Preempt() eliminates a lot of hassles.
//The concern is about changing
//que links while the winmgr task
//is updating the ode or screen.

//The Window mgr suspends this
//task while updating the ode.It
//will not be interrupted and with this
//preempt, we will not be interrupted.
//There is little downside to Preempt()
//since we will yield during GetMsg().
  Preempt(OFF);


  Fs->win_inhibit|=WIF_DBL_CLICK;
  WordStat;

  MenuPush(
"File {"
"  Abort(,CH_SHIFT_ESC);"
"  Exit(,CH_ESC);"
"}"
"Play {"
"  Restart(,'\n');"
"}"
  );

  Init;
  DocCursor;
  DocClear;
  Fs->draw_it=&DrawIt;

  try {
    while (TRUE) {
      msg_code=GetMsg(&p1,&p2,1<<MSG_IP_L_DOWN|1<<MSG_IP_R_DOWN|1<<MSG_IP_R_UP|1<<MSG_KEY_DOWN);
      switch (msg_code) {
	case MSG_IP_L_DOWN:
	  PlaceMass(p1,p2);
	  break;
	case MSG_IP_R_DOWN:
	  tempm1=MassFind(ode,p1,p2);
	  tempm2=NULL;
	  break;
	case MSG_IP_R_UP:
	  if (tempm1 && (tempm2=MassFind(ode,p1,p2)) && tempm1!=tempm2)
	    PlaceSpring(tempm1,tempm2);
	  tempm1=tempm2=NULL;
	  break;
	case MSG_KEY_DOWN:
	  switch (p1) {
	    case '\n':
	      CleanUp;
	      Init;
	      break;
	    case CH_SHIFT_ESC:
	    case CH_ESC:
	      goto ms_done;
	  }
	  break;
      }
    }
ms_done: //Don't goto out of try
    GetMsg(,,1<<MSG_KEY_UP);
  } catch
    CatchAll;
  SettingsPop;
  CleanUp;
  MenuPop;
}