Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
dining.C
Package: threads-2.0.tar.gz [view]
Upload User: shtangtang
Upload Date: 2007-01-04
Package Size: 167k
Code Size: 1k
Category:
Linux-Unix program
Development Platform:
Unix_Linux
- #define __THREADS_MAIN
- #include <thread.h>
- #include "philosopher.h"
- #include "dining.h"
- dining::dining(int p_no)
- {
- p_fork = new mutex[p_no];
- for( philosophers=0;philosophers<p_no;philosophers++ )
- (void)new philosopher(philosophers,p_no,this);
- }
- dining::~dining()
- {
- do {
- cout << philosophers << " are left." << endl;
- p_finish.wait(p_single);
- } while( philosophers-- > 1 );
- cout << "Diner closing." << endl;
- }
- void dining::finished()
- {
- p_single.lock();
- p_finish.signal();
- p_single.unlock();
- }
- mutex& dining::fork(int p_no)
- {
- return p_fork[p_no];
- }