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
test_sleep.c
Package: mysql-3.23.35.tar.gz [view]
Upload User: tsgydb
Upload Date: 2007-04-14
Package Size: 10674k
Code Size: 1k
Category:
MySQL
Development Platform:
Visual C++
- /* ==== test_switch.c ============================================================
- * Copyright (c) 1993 by Chris Provenzano, proven@athena.mit.edu
- *
- * Description : Test context switch functionality.
- *
- * 1.00 93/08/04 proven
- * -Started coding this file.
- */
- #include <pthread.h>
- #include <stdio.h>
- const char buf[] = "abcdefghijklimnopqrstuvwxyz";
- int fd = 1;
- void* new_thread(void* arg)
- {
- int i;
- for (i = 0; i < 10; i++) {
- write(fd, buf + (long) arg, 1);
- sleep(1);
- }
- }
- main()
- {
- pthread_t thread;
- int count = 2;
- long i;
- pthread_init();
- printf("Going to sleepn");
- sleep(10);
- printf("Done sleepingn");
- for(i = 0; i < count; i++) {
- if (pthread_create(&thread, NULL, new_thread, (void *) i)) {
- printf("error creating new thread %dn", i);
- }
- }
- pthread_exit(NULL);
- fprintf(stderr, "pthread_exit returnedn");
- exit(1);
- }