#include <cstdlib>
#include <iostream>
#include <pthread.h>
#include <sys/neutrino.h>
int channelSender; //Channel for Sender
int channelReceiver; //Channel for Receiver
void* SenderProc(void *param);
void* ReceiverProc(void *param);
void* KindSendMedium (void *param);
void* KindAckMedia(void *param);
int main(int argc, char *argv[]) {
//std::cout << "Welcome to the Momentics IDE" << std::endl;
pthread_t sender, receiver, kindsendmed, kindackmed;
pthread_attr_t attr;
//Initialize channels
channelSender = ChannelCreate(0);
channelReceiver = ChannelCreate(0);
//Create 4 threads
pthread_attr_init( &attr );
pthread_create( &sender, &attr, &SenderProc, (void *)"XMODEM-Clarified.txt" );
pthread_create( &receiver, &attr, &ReceiverProc, (void *)"XMODEM-Output.dat" );
pthread_create( &kindsendmed, &attr, &KindSendMedium, NULL );
pthread_create( &kindackmed, &attr, &KindAckMedia, NULL );
//Waiting for transmision to be over
pthread_join(sender, NULL);
pthread_join(receiver, NULL);
//The other two threads die out upon exit
//pthread_join(kindsendmed, NULL);
//pthread_join(kindackmed, NULL);
//Destroy channels
ChannelDestroy(channelSender);
ChannelDestroy(channelReceiver);
return EXIT_SUCCESS;
}
댓글 없음:
댓글 쓰기