Nucleus to Linux porting

I am new to Linux programming and my work involves changing an abstraction layer which made Nucleus calls, to Linux calls.

In Case of Events Nucleus has calls like
NU_Set_Events()
NU_Retrieve_Events()

Can I use the POSIX thread conditional variables for Linux?
Can I use the System V calls for events for threads of a same process? Please let me know how I can go about doing it.
-------------------------------------------------------------------------------------------
In Case of Pipes Nucleus has calls like
NU_Send_To_Pipe()
NU_Receive_From_Pipe()
NU_Send_To_Front_Of_Pipe()

These calls have a suspend as one parameter by which the pipe can be suspended or can return back immediately if the pipe cannot be written into or read from.
But in Linux, in case of pipes created by pipe() or open() system call, the pipe has only the suspend functionality where in it will suspend till it can read from or write to pipe.

Moreover in Nucleus, NU_Send_To_Front_Of_Pipe() writes to front of the pipe for urgent messages.

How do I implement these functionalities in Linux?

-------------------------------------------------------------------------------------------
In case of Mutexes and Semaphores,
The Nucleus has functionalities where the thread can try locking mutexes or acquiring semaphores for a specified amount of time, after which they return back if mutex/semaphore is unavailable.
How can this be implemented in Linux? Can nanosleep() be used here?

Kindly suggest some solutions.
Thanks.

Taklu.

I believe you can make pipes blocking or not with a fcntl call.

int set_nonblocking(int fd)
{
  int oldflags = fcntl(fd, F_GETFL, 0);
  if(oldflags < 0) return(-1);

  oldflags |= O_NONBLOCK;
  return(fcntl(fd, F_SETFL, oldflags));
}

int set_blocking(int fd)
{
  int oldflags=fcntl(fd, F_GETFL, 0);
  if(oldflags < 0) return(-1);
  oldflags &= ~O_NONBLOCK;
  return(fcntl(fd, F_SETFL, oldflags));
}

I've also observed that, if you need to flush a pipe, writing a newline to it will cause the pipe to stop holding its buffer and let the current contents be read. (with an extra newline on the end, of course.)

Yes, linux has nanosleep.

As for writing to the front of the pipe for urgent messages... That sounds awful strange for a stream socket -- your message might end up in the middle of another! Are nucleus sockets packet-based to avoid this? Ordinary linux pipes are stream ones, but Linux also has UNIX domain sockets, which are sort of a pipe/socket hybrid that can be either stream or packet based.