Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7867111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:37:17+00:00 2026-06-03T00:37:17+00:00

I am trying to solve readers-writers problem . The following functions is supposed to

  • 0

I am trying to solve readers-writers problem. The following functions is supposed to create named semaphores.

void createSems(void){

if((sem_counter = sem_open("counter", O_CREAT, 0660, 1)) == SEM_FAILED)
    printErrorAndKill("sem_open_counter");
if((sem_reader = sem_open("reader", O_CREAT, 0660, 1)) == SEM_FAILED)
    printErrorAndKill("sem_open_reader");    
if((sem_writer = sem_open("writer", O_CREAT, 0660, 1)) == SEM_FAILED)
    printErrorAndKill("sem_open_writer");  
if((sem_writer = sem_open("mutex1", O_CREAT, 0660, 1)) == SEM_FAILED)
    printErrorAndKill("mutex1");
if((sem_writer = sem_open("mutex2", O_CREAT, 0660, 1)) == SEM_FAILED)
    printErrorAndKill("mutex2");
if((sem_writer = sem_open("mutex3", O_CREAT, 0660, 1)) == SEM_FAILED)
    printErrorAndKill("mutex3");

}

void printErrorAndKill (const char *functionName){    
perror(functionName);
printf("%s: %s\n",functionName, strerror(errno));
exit(1);
}

Everything is working as expected on my MBP 10.7.3. But when I test it on school server I get the following output.

sem_open_reader: Permission denied
sem_open_reader: Illegal seek

The first semaphore is created successfully every time. I tried to google the error but with no succes or any connection to sem_open.

My question is am I doing something wrong when I am creating semaphores or the problem is somewhere else?

UPDATE

I did more testing and I eventually found out that it has nothing to do with illegal seek. I got rid of the line “perror(functionName);” just to found out the problem is just with permissions. Some names were reserved on our school OS so I just had to come with some more relevant names.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T00:37:18+00:00Added an answer on June 3, 2026 at 12:37 am

    The “Illegal seek” message is probably caused by perror(). The man page for perror on my system says: “Note that errno is undefined after a successful library call: this call may well change this variable, even though it succeeds, for example because it internally used some other library function that failed.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to solve the readers-writers problem with writer preference in Java using
I'm trying to solve the following problem: I have a download button that when
Trying to solve this problem: I have the following set of divs that when
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
Trying to solve this problem . I would like to learn how the bootstrapper
I'm trying to solve the problem here but I don't know why my code
I am trying to solve this problem. I have a series of SELECT statements
I'm trying to solve the Adding Reversed Numbers problem (ADDREV) at the Sphere Online
edit: I was trying to solve a spoj problem. Here is the link to
I am trying to solve this problem. I am reading data from csv fiile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.