/*
* mutex.h
* scheduling
*
*/
#ifndef MUTEX_H
#define MUTEX_H
#include<pthread.h>
class Mutex
{
private:
pthread_mutex_t mutex;
public:
/** Initializing the mutex
*/
Mutex();
/** Destroy the mutex
*/
~Mutex();
/** Acquire the lock
* @return The return value of pthread_mutex_lock().
*/
int Lock();
/** Release the lock
* @return The return value of pthread_mutex_unlock().
*/
int Unlock();
};
#endif
I've double checked and both codes are in the same directory and just in case you need to know, I am using Eclipse C/C++ and MinGW. Hopefully someone can help me out here so I can actually get started on this assignment!
That sort of worked.... mutex.cpp doesn't have an error anymore but now I have an error message in mutex.h saying:
`pthread_mutex_t' does not name a type (on line 15)
as well as
pthread.h: no such file
Also, I forgot to mention that a Makefile is included with the codes as well but I don't know how to use it within Eclipse to build the codes. Do I need this Makefile or can I just build everything using eclipse?
pthread.h is generally for POSIX systems like FreeBSD, NetBSD, GNU/Linux, Mac OS X and Solaris, but Microsoft Windows implementations also exist. For example, the pthreads-w32 is available and supports a subset of the Pthread API for the Windows 32-bit platform.
If you are working in windows it wont work. U have to look forpthreads-w32 .
pthread.h is generally for POSIX systems like FreeBSD, NetBSD, GNU/Linux, Mac OS X and Solaris, but Microsoft Windows implementations also exist. For example, the pthreads-w32 is available and supports a subset of the Pthread API for the Windows 32-bit platform.
If you are working in windows it wont work. U have to look for
pthreads-w32 .
Thanks for pointing that out. I tired compiling it on my school's Linux computer and there wasn't a problem. I'm not sure whether our instructor is okay with us using pthreads-w32 so I'll have to ask her about that...
Also, this is for another assignment but what about arpa/inet.h or sys/socket.h? Are those also only supported by unix-like systems?How about you just ask your teacher since it will be easier and more straight forward.