History of Idiom 22 > diff from v100 to v101
Edit summary for version 101 by a:
New Erlang implementation by user [a]
New Erlang implementation by user [a]
↷
Version 100
2020-10-10, 19:12:49
Version 101
2020-11-09, 08:52:56
Idiom #22 Convert string to integer
Extract integer value i from its string representation s (in radix 10)
Idiom #22 Convert string to integer
Extract integer value i from its string representation s (in radix 10)
Variables
i,sVariables
i,sExtra Keywords
int base conversionExtra Keywords
int base conversionCode
#include <pthread.h>
#include <semaphore.h>
#include <stdio.h>
/*
This program provides a possible solution for first readers writers problem using mutex and semaphore.
I have used 10 readers and 5 producers to demonstrate the solution. You can always play with these values.
*/
sem_t wrt;
pthread_mutex_t mutex;
int cnt = 1;
int numreader = 0;
void *writer(void *wno)
{
sem_wait(&wrt);
cnt = cnt*2;
printf("Writer %d modified cnt to %d\n",(*((int *)wno)),cnt);
sem_post(&wrt);