c_cpp C语言-CS520
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp C语言-CS520相关的知识,希望对你有一定的参考价值。
# ifdef DEBUG
print_array(samples, s);
# endif
pthread_t *thread_handles = malloc(thread_count * sizeof(pthread_t));
long thread;
for (thread = 0; thread < thread_count; thread++) {
pthread_create(thread_handles + thread, NULL, Multiply, (void*) thread);
}
for (thread = 0; thread < thread_count; thread++) {
pthread_join(*(thread_handles + thread), NULL);
}
void* Multiply(void* rank) {
long my_rank = (long) rank;
long i;
long start = (long) (n / thread_count) * my_rank;
long end = (long) (n / thread_count) * (my_rank + 1);
for (i = start; i < end; i++) {
*(array_Y + i) = *(array_X + i) * alpha;
}
return NULL;
}
void Usage(char* prog_name) {
fprintf(stderr, "usage: %s <number of threads> <n>\n", prog_name);
exit(0);
}
#include <pthread.h>
pthread_mutex_t mutex;
pthread_mutex_init(&mutex, NULL);
pthread_mutex_destroy(&mutex);
pthread_mutex_lock(&mutex);
pthread_mutex_unlock(&mutex);
以上是关于c_cpp C语言-CS520的主要内容,如果未能解决你的问题,请参考以下文章
c_cpp conditions.c#CS50
c_cpp answer.c#CS50
c_cpp CS50 vigenere.c
c_cpp cs_stepper_01.ino
520表白C语言开发《浪漫流星雨》表白程序,源码来了!
c_cpp C语言