2012-10-11 67 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