1 Replies - 439 Views - Last Post: 10 December 2012 - 06:19 PM Rate Topic: -----

#1 seraph++   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 10-December 12

linux c communication

Posted 10 December 2012 - 06:14 PM

Process (coordinator) process creates 10 jobs (pool of processes). Workflows waiting to be awakened by the coordinator perform a job and wait again. Coordinator transmits tag (integer) of the first process and wakes him up. The process adds one to bookmark and submit it to the next process, signaling that the coordinator. Coordinator wakes up the next process, which performs same actions etc. After going through all of marker processes coordinator visualize its content. For signaling processes to use signals to transmit marker to use shared memory.

i write like this but im not sure that is correct.sorry about my english.
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

pthread_mutex_t m;
int global_marker = 0;

void* increment_globalMarker(void *arg){
	int i;
	int number_of_thread = *((int *)arg);
	for (i=0;i<100000; i++){
	if(ptrhread_mutex_trylock(&m) == 0)break;
	printf("\n Number of executed thread is: %d",number_of_thread);
	global_marker ++;
int main(){
	int counter;
	pthread_t increment_thread[10];
	int thread_num[] = {0,1,2,3,4,5,6,7,8,9};
	printf("\n---THE INITIAL VALUE OF GLOBAL MARKER IS: %d",global_marker);

	pthread_mutex_init(&m, NULL);

	for(counter=0; counter<10; counter++){
	pthread_create(&increment_thread[counter], NULL, &increment_globalMarker, &thread_num[counter]);
	pthread_join(increment_thread[0], NULL);
	pthread_join(increment_thread[1], NULL);
	pthread_join(increment_thread[2], NULL);
	pthread_join(increment_thread[3], NULL);
	pthread_join(increment_thread[4], NULL);
	pthread_join(increment_thread[5], NULL);
	pthread_join(increment_thread[6], NULL);
	pthread_join(increment_thread[7], NULL);
	pthread_join(increment_thread[8], NULL);
	pthread_join(increment_thread[9], NULL);

	printf("\n THE END OF VALUE GLOBAL MARKERS %d",global_marker);

Is This A Good Question/Topic? 0
  • +

Replies To: linux c communication

#2 jjl   User is offline

  • Engineer
  • member icon

Reputation: 1270
  • View blog
  • Posts: 4,998
  • Joined: 09-June 09

Re: linux c communication

Posted 10 December 2012 - 06:19 PM


Process (coordinator) process creates 10 jobs (pool of processes).

A process is an instance of a program, not a thread. If you are looking to create multiple processes, then take a look at fork and exec
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1