Group 2 Assignment 1
Group 2 Assignment 1
multicore architecture
How Did the Evolution of Processor Technology Lead to the Rise of Multi-
Core Architectures?
(d) How Does Multi-Core Systems Help Overcome the Reasons Behind the
Shift Towards Parallel Computing
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#define NUM_THREADS 4
#define ARRAY_SIZE 1000000
int array[ARRAY_SIZE];
long long results[NUM_THREADS];
int main() {
// Initialize array with random values
for (int i = 0; i < ARRAY_SIZE; i++) {
array[i] = rand() % 100;
}
pthread_t threads[NUM_THREADS];
// Create threads
for (int i = 0; i < NUM_THREADS; i++) {
pthread_create(&threads[i], NULL, compute_sum, (void
*)(size_t)i);
}
pthread_exit(NULL);
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <sys/wait.h>
#include <unistd.h>
#define NUM_PROCESSES 4
#define ARRAY_SIZE 1000000
int array[ARRAY_SIZE];
int main() {
// Initialize array with random values
for (int i = 0; i < ARRAY_SIZE; i++) {
array[i] = rand() % 100;
}
pid_t pids[NUM_PROCESSES];
long long results[NUM_PROCESSES];