Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,nitial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Navbar_1</title>
<link rel="stylesheet" href="pro.css">
</head>
<body>
@SrajenSingh
SrajenSingh / cat.c
Created April 16, 2018 13:33
cat_mouse_synchronization
#include <sys/types.h>
#include <pthread.h>
#include <semaphore.h>
#include<unistd.h>
#include<stdio.h>
/* this must be called before any calls to cat_eat or mouse_eat */
extern int initialize_bowls(unsigned int bowlcount);
extern void cat_eat(unsigned int bowlnumber);
#include<stdio.h>
int main()
{
int x;
printf("Press 1 for First Come First Serve:");
printf("\n\nPress 2 for Shortest Job First:");
printf("\n\nPress 3 for Ideal Condition:");
scanf("%d",&x);
printf("\n\n");
switch(x)