Might have fixed 64-bit issues. :)
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401499
This commit is contained in:
parent
c2a4bb7b9a
commit
2a752c3732
2 changed files with 8 additions and 6 deletions
|
@ -15,15 +15,16 @@ int alive = 1;
|
||||||
|
|
||||||
int ThreadFunc(void *data)
|
int ThreadFunc(void *data)
|
||||||
{
|
{
|
||||||
|
uintptr_t threadnum = (uintptr_t)data;
|
||||||
while ( alive ) {
|
while ( alive ) {
|
||||||
SDL_SemWait(sem);
|
SDL_SemWait(sem);
|
||||||
fprintf(stderr, "Thread number %d has got the semaphore (value = %d)!\n", (int)data, SDL_SemValue(sem));
|
fprintf(stderr, "Thread number %d has got the semaphore (value = %d)!\n", threadnum, SDL_SemValue(sem));
|
||||||
SDL_Delay(200);
|
SDL_Delay(200);
|
||||||
SDL_SemPost(sem);
|
SDL_SemPost(sem);
|
||||||
fprintf(stderr, "Thread number %d has released the semaphore (value = %d)!\n", (int)data, SDL_SemValue(sem));
|
fprintf(stderr, "Thread number %d has released the semaphore (value = %d)!\n", threadnum, SDL_SemValue(sem));
|
||||||
SDL_Delay(1); /* For the scheduler */
|
SDL_Delay(1); /* For the scheduler */
|
||||||
}
|
}
|
||||||
printf("Thread number %d exiting.\n", (int)data);
|
printf("Thread number %d exiting.\n", threadnum);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +36,8 @@ static void killed(int sig)
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
SDL_Thread *threads[NUM_THREADS];
|
SDL_Thread *threads[NUM_THREADS];
|
||||||
int i, init_sem;
|
uintptr_t i;
|
||||||
|
int init_sem;
|
||||||
|
|
||||||
if(argc < 2) {
|
if(argc < 2) {
|
||||||
fprintf(stderr,"Usage: %s init_value\n", argv[0]);
|
fprintf(stderr,"Usage: %s init_value\n", argv[0]);
|
||||||
|
|
|
@ -31,7 +31,7 @@ int ThreadFunc(void *data) {
|
||||||
SDL_Thread *sub_threads[NUMTHREADS];
|
SDL_Thread *sub_threads[NUMTHREADS];
|
||||||
int flags[NUMTHREADS];
|
int flags[NUMTHREADS];
|
||||||
int i;
|
int i;
|
||||||
int tid = (int ) data;
|
uintptr_t tid = (uintptr_t)data;
|
||||||
|
|
||||||
fprintf(stderr, "Creating Thread %d\n", tid);
|
fprintf(stderr, "Creating Thread %d\n", tid);
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ int ThreadFunc(void *data) {
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
SDL_Thread *threads[NUMTHREADS];
|
SDL_Thread *threads[NUMTHREADS];
|
||||||
int i;
|
uintptr_t i;
|
||||||
|
|
||||||
/* Load the SDL library */
|
/* Load the SDL library */
|
||||||
if ( SDL_Init(0) < 0 ) {
|
if ( SDL_Init(0) < 0 ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue