Nucleus to Linux porting


 
Thread Tools Search this Thread
Top Forums Programming Nucleus to Linux porting
# 1  
Old 11-16-2008
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.
# 2  
Old 11-17-2008
I believe you can make pipes blocking or not with a fcntl call.

Code:
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Porting script from Solaris to Linux

I have a script which has commands that are located in different paths on my Linux o/s than on Solaris. For example, to make uname work, I need to do it this way in Solaris: my $host= `/usr/bin/uname -n` But in Linux it is: my $host = `/bin/uname -n`I have this issue with at least 5... (8 Replies)
Discussion started by: newbie2010
8 Replies

2. Programming

Porting Rogue Wave to Linux

I am challenged with porting an old application from Solaris to Red Hat. The application uses Rogue Wave and I am searching for a Red Hat implementation. Your help is appreciated! (2 Replies)
Discussion started by: FunkyWinkerbean
2 Replies

3. Shell Programming and Scripting

Porting from Solaris to Linux

Can any one please help the use of "cu command in Solaris" and as well as in Linux :confused: (1 Reply)
Discussion started by: sabee.prakash
1 Replies

4. Solaris

Porting a Linux Driver to Solaris

Hi all, Has anyone experience with proting a Linux driver (C-code) to Solaris 10? I have a Sunix SATA card with a inicio1622 chipset, but no driver available. From the website of inicio I downloaded the drivercode for Linux 2.4. Having done some investigation I found a Solaris driver... (4 Replies)
Discussion started by: longwave
4 Replies

5. Filesystems, Disks and Memory

Porting OSE to Linux

Hi, I was trying to port efs_mount(OSE system call) to a LInux.The efs_mount function is used to mount a volume on the indicated device dev.Upon successful completion of this OSE sytem call a volume manager (VM) will be available through which files on this volume are accessed. The Syntax for... (4 Replies)
Discussion started by: roshantraj30
4 Replies

6. Linux

Porting DHCP from Linux to VxWorks

Hello All, I have a code of DHCP which is implemented on Linux. During porting this code from Linux to VxWorks, I come up with following errors:- jects\freedom\ap\udhcp\socket.c C:\projects\freedom\ap\udhcp\socket.c: In function `read_interface': C:\projects\freedom\ap\udhcp\socket.c:79:... (1 Reply)
Discussion started by: Sunny Shivam
1 Replies

7. Linux

when porting from HP-UX to Linux

helo, i m porting HP-UX socket application to Linux SSL-socket application. I have use htonl() in HP-UX. so when i use it in Linux, data transf is not done and application become soem time crashed. now when i remove htonl() in linux, then i got data but it will not proper order or some data may... (1 Reply)
Discussion started by: amitpansuria
1 Replies

8. Programming

Porting From Linux To Hpux

Gents, i'm a senior applications developer and need to port a Linux server application ( no additional / special libraries or unique header files ) to a HPUX enviroment. Any chance to compile it on the Linux using flags to create an HPUX binary with gcc? (8 Replies)
Discussion started by: anak0nda
8 Replies

9. UNIX for Dummies Questions & Answers

HP-UX to linux porting

Hi all, i wanted to port some HP-UX code to linux. can anybody point to some documents or resources that would help me in doing the porting.. thanks in advance Arun Prakash (0 Replies)
Discussion started by: arunprakash
0 Replies

10. Programming

Porting Win32 application into Linux

I need port Win32 console application, which was developed with MS Visual Studio 6.0 (without MFC using) into Linux. What is the best way to port project? Are there any standard tools or decisions? Thank you in advance, Sergey (0 Replies)
Discussion started by: Sergeyy
0 Replies
Login or Register to Ask a Question