다음과 같은 소스에서
#include
#include
#include
#include
#include
void *do_write(void *data)
{
int fp;
struct flock lType;
fp = open("./test.txt", O_RDWR | O_CREAT);
lType.l_type = F_WRLCK;
lType.l_whence = SEEK_SET;
lType.l_start = 2;
lType.l_len = 2;
fcntl(fp, F_SETLKW, lType);
printf("1 is lock now!!\n");
sleep(4);
lType.l_type = F_UNLCK;
fcntl(fp, F_SETLKW, lType);
printf("1 is unlock now!!\n");
sleep(5);
}
void *do_read(void *data)
{
int fp;