2012-10-11 66 views
0

我正在寫一個多線程的Web服務器,1個調度線程,1個排隊線程和n個執行線程在C++中,這是一個作業問題。我不問代碼。我爲服務器創建了一個流程。你能告訴我流量是否正確?多線程的Web服務器流程圖

main()    //queuing thread 
{ 
    define sockets 
    create scheduling thread 
    create queue of n execution threads //n execution threads 
    accpet connection infinetly 
    { 
      insert the request in a queue 
    } 
} 

scheduling thread   // scheduling thread 
{ 
     job = take each request from queue (FCFS or SJF) 
     take 1 thread from queue of execution threads and assign the job request 
    } 

問題是否正確?我只需要方向。提前感謝。

+0

感謝提示@cHao。我不會「濫用」標誌爲:)將簡單刪除:)乾杯 – sehe

回答

1

你的僞代碼對我來說看起來很合理。

+0

非常感謝... ...更多的問題。當分配工作,我將有鎖定和解鎖線程的互斥。將條件變量所有線程都一樣,或者每個線程都不一樣? – user1429322

+0

您需要爲每個線程提供獨特的互斥鎖或鎖定機制。 – Chimera