void CalculatePSJF() { struct ListNode *temp=front; int totaltime=0; int total=0; float totalwaitingtime=0; float totalturnaroundtime =0; while(!JobFinished()) { struct ListNode *temptemp = front; int pos = CalculatePosition(totaltime); if(pos<0) { printf("Encountered some error while calculating."); exit(-3); } AddWaitingToRest(pos,totaltime); while(pos--) { temptemp= temptemp->next; //Takes the pointer to the right position } temptemp->rembt -= 1; totaltime += 1; if(temptemp->rembt == 0) { temptemp->tt = totaltime - temptemp->at; } DisplayQueue(); printf("Is job finished? %d\n",JobFinished()); } DisplayQueue(); total = LengthofQueue(); temp = front; while(temp) { totalwaitingtime += temp->wt; totalturnaroundtime += temp->tt; temp = temp->next; } printf("Average Waiting time is: %f \n",totalwaitingtime/total ); printf("Average Turnaround time is: %f \n",totalturnaroundtime/total ); }
void CDlgDeiceQueue::OnNewDeicePad() { //std::vector<ALTObject> vObject; //ALTObject::GetObjectList(ALT_DEICEBAY,m_nProjID,vObject); if ((int)m_vPadList.size() == 0) { ::AfxMessageBox(_T("No deice pad to be selected"),MB_OK|MB_ICONQUESTION); return; } CDlgSelectDeicePads dlg(m_nProjID); if (dlg.DoModal() == IDOK) { for (int i = 0; i < m_QueueList->GetCount(); i++) { DeicePadQueueItem* pItem = m_QueueList->GetItem(i); if (dlg.GetSelDeicepadsFamilyID() == pItem->getDeicePadID()) { ::AfxMessageBox(_T("The deicepad is exist")); return; } } m_pCurDeiceItem = new DeicePadQueueItem(); m_pCurDeiceItem->setDeicePadID(dlg.GetSelDeicepadsFamilyID()); int nIndex = m_wndListbox.AddString(dlg.GetSelDeicepadsFamilyName()); m_wndListbox.SetItemData(nIndex,(DWORD_PTR)m_pCurDeiceItem); m_QueueList->AddItem(m_pCurDeiceItem); DisplayQueue(m_pCurDeiceItem); GetDlgItem(IDC_BUTTON_SAVE)->EnableWindow(TRUE); m_wndDeicePadToolbar.GetToolBarCtrl().EnableButton(ID_TOOLBAR_DEL,FALSE); } }
int main() { printf("Enter the queue size: "); scanf("%d", &iMax); int iChoice; while(1) { printf("\n1. Enqueue\n2. Dequeue\n3. Display\n4. Exit\nEnter your choice:"); scanf("%d", &iChoice); switch(iChoice) { case 1: InsertData(); break; case 2: DeleteValue(); break; case 3: DisplayQueue(); break; case 4: return 0; } } return 0; }
void CDlgDeiceQueue::OnLbnSelchangeListDeicepad() { // TODO: Add your control notification handler code here int nItem = m_wndListbox.GetCurSel(); if (nItem != LB_ERR) { m_pCurDeiceItem = (DeicePadQueueItem*)m_wndListbox.GetItemData(nItem); if (m_pCurDeiceItem != NULL) { DisplayQueue(m_pCurDeiceItem); } } m_wndTreeCtrl.SelectItem(NULL); OnChangeToolbarStatus(); }