Adjusted main function logic

This commit is contained in:
TriantaTV 2022-09-30 01:14:57 -05:00
parent 9522bce20b
commit 86c7c0a3e5
2 changed files with 6 additions and 9 deletions

View File

@ -11,7 +11,7 @@
#define THINKING 0 /*philosopher is thinking*/ #define THINKING 0 /*philosopher is thinking*/
#define HUNGRY 1 /*philosopher is trying to get forks*/ #define HUNGRY 1 /*philosopher is trying to get forks*/
#define EATING 2 /*philosopher is eating*/ #define EATING 2 /*philosopher is eating*/
pthread_mutex_t mutex; /*mutual exclusion for critical region*/ // pthread_mutex_t mutex; /*mutual exclusion for critical region*/
typedef struct PhilosopherData { typedef struct PhilosopherData {
@ -50,18 +50,15 @@ void Up();
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
if (argc < 2) if (argc < 2)
{
printf("Too few arguments, exiting...\n"); printf("Too few arguments, exiting...\n");
return 0;
}
if (argc > 2) if (argc > 2)
{
printf("Too many arguments, exiting...\n"); printf("Too many arguments, exiting...\n");
return 0; if (argc == 2)
{
int philosopherTotal;
philosopherTotal = GetPhilosopherCount(argv[1]);
PhilosopherInit(philosopherTotal);
} }
int philosopherTotal;
philosopherTotal = GetPhilosopherCount(argv[1]);
PhilosopherInit(philosopherTotal);
return 0; return 0;
} }

Binary file not shown.