Find Jobs
Hire Freelancers

A C Program (Semaphores)

$10-30 CAD

Completed
Posted over 3 years ago

$10-30 CAD

Paid on delivery
Most of the code such as reading the input file, creating the threads etc. is provided in the file "inital.c". Your task is to implement following synchronization logic with the help of POSIX semaphores, So 80-90% of the code is done except the synchronization logic: • Only one thread can be in its critical section at any time in this process. • The first thread, in terms of creation time, enters first in its critical section. • After that threads are permitted to perform their critical section based on their ID. • Threads are given IDs in the format txy where x and y are digits (0-9). Thread IDs are unique. • Threads may have same or different start_time. Thread entries in the input file can be in any order. • The “y” in thread IDs thus will either be an even digit or odd digit. • After the first thread, the next thread that will be permitted to perform its critical section must be the one in which “y” is different i.e. if “y” was even in first thread then in the next it must be odd or vice versa. • For the rest of the process, you must follow the same scheme i.e. two threads with odd “y” or even “y” can not perform critical section simultaneously. • Since synchronization may lead to deadlock or starvation, you have to make sure that your solution is deadlock free i.e. your program must terminate successfully, and all the threads must perform their critical section. • One extended form of starvation will be that towards the end, we have all odd or all even processes left, and they are all locked because there are no other type (odd/even) of threads left. Once the process reaches to that stage, you must let them perform their critical section to avoid starvation and progress towards the end of the process. However, you must make sure that there are no other threads coming in future which could help avoid this situation. If there is chance for more threads coming, then you will hold this till then. You are provided a skeleton code in the file "intial.c" that is provided below. Some functions are completely implemented, and some are partially implemented. Additionally, you can write your own functions if required. Complete the program as per following details so that we can have functionality as described above. Write all the code in single C file: 1. The code provided reads the content of file for you and populate the threads information in a dynamic array of type struct thread. You may add some more members to this data structure if required. If you want to initialize those members, then you can possibly do that during the file read. 2. The main() already contains the code to create and invoke threads. However, there is no synchronization logic added to it. If required, you will add some suitable code in the while loops to perform the tasks required. 3. The threadRun() function also contains the code that a thread must run. However, again the synchronization logic is missing. Add the suitable code before and after the critical section. 4. You will need to create and use POSIX semaphore(s) to implement the required logic. I also provided a sample input file for this program and an image of the sample output expected.
Project ID: 26760115

About the project

7 proposals
Remote project
Active 4 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
I have 8+ year of experience in C & C++ Developing program. Semaphores Thread Sync I can do all. Lets have a chat and discuss in detail. I have read your requirements once we clear our requirements and understood all things we can start work. Inbox me and let's talk to get started!
$30 CAD in 7 days
5.0 (10 reviews)
4.1
4.1
7 freelancers are bidding on average $118 CAD for this job
User Avatar
Hi there, I do C programming and have good command in threading and synchronization. I went through your requirements and I would like to do this project if given the opportunity. Let me know if you are interested.
$30 CAD in 1 day
4.9 (1662 reviews)
8.0
8.0
User Avatar
I am very proficient in c and c++. I have 18 years c++ developing experience now, and have worked for more than 10 years. My work is online game developing, and mainly focus on server side, using c++ under Linux environment. I made many great projects using c++, for example, I made the tools which could convert java codes into c++ scripts, of course garbage collection included, this was very similar to a compiler, and was very complex. I also made our own mobile game using c++, I can show you the demo of client, if you like. I am very proficient in java also. I have a very good review on Freelancer.com, I never miss a project once I accept the job, you can check my review. Trust me, please let expert help you.
$150 CAD in 3 days
4.9 (230 reviews)
7.4
7.4
User Avatar
Hi I have done many c and c++ projects. Kindly contact to share more details about your project in chat. Thank you
$70 CAD in 7 days
4.9 (106 reviews)
6.8
6.8
User Avatar
Hello, I just saw your offer. I believe that I have adequate knowledge and experience to build an exclusive c++ application. With me you'll gain guaranteed quality work for your application. I have immense experience in creating high performant, hyperthreaded and multitasking applications. I have worked in cplusplus on projects related to databases, parallel pipelining, compilers,distributed systems and trading software. I am done multiples project on multithreading so i am pretty sure that i will be able to complete it If the above offer sounds like something you would be interested in, I’d love to hear from you. Looking forward to hearing from you
$30 CAD in 7 days
5.0 (7 reviews)
2.2
2.2

About the client

Flag of CANADA
Toronto, Canada
5.0
2
Payment method verified
Member since Jun 7, 2020

Client Verification

Other jobs from this client

A C Program
$10-30 CAD
Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759) & Freelancer Online India Private Limited (CIN U93000HR2011FTC043854)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.