Sponsored Content
Full Discussion: Nucleus to Linux porting
Top Forums Programming Nucleus to Linux porting Post 302259142 by Corona688 on Monday 17th of November 2008 10:56:42 AM
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.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
pipe(2) 							System Calls Manual							   pipe(2)

NAME
pipe - Creates an interprocess channel SYNOPSIS
#include <unistd.h> int pipe ( int filedes[2] ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: pipe(): XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the address of an array of two integers into which the new file descriptors are placed. DESCRIPTION
The pipe() function creates a unidirectional interprocess channel called a pipe, and returns two file descriptors, filedes[0] and filedes[1]. The file descriptor specified by the filedes[0] parameter is opened for reading and the file descriptor specified by the filedes[1] parameter is opened for writing. Their integer values will be the two lowest available at the time of the call to the pipe() function. A process has the pipe open for reading if it has a file descriptor open that refers to the read end, filedes[0]. A process has the pipe open for writing if it has a file descriptor open that refers to the write end, filedes[1]. A read on file descriptor filedes[0] accesses the data written to filedes[1] on a first-in, first-out (FIFO) basis. System V Compatibility The pipe() function creates an interprocess channel called a pipe and returns two file descriptors, filedes[0] and filedes[1]. Both file descriptors are STREAMS based and are bidirectional. Data written on filedes[0] appears on filedes[1] and vice versa. Data is read in a first-in, first-out (FIFO) basis. Under both behaviors, the O_NONBLOCK and the FD_CLOEXC flags are set clear on both file descriptors. (The fcntl() function can be used to set the O_NONBLOCK flag.) Upon successful completion, the pipe() function marks the st_atime, st_ctime and st_mtime fields of the pipe for update. NOTES
When a read or write system call on a pipe is interrupted by a signal and no bytes have been transferred through the pipe, the read or write system call returns a -1 and errno is set to [EINTR]. This behavior is different from previous releases, when both system calls either restarted the transfer or caused errno to be set to [EINTR], depending on the setting of the SA_RESTART flag for the interrupting signal. As a result of this change, applications must now either handle the [EINTR] return or block any expected signals for the duration of the read or write operation. [Tru64 UNIX] When compiled in the X/Open UNIX environment, calls to the pipe() function are internally renamed by prepending _E to the function name. When you are debugging a module that includes the pipe() function and for which _XOPEN_SOURCE_EXTENDED has been defined, use _Epipe to refer to the pipe() call. See standards(5) for further information. RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. If the pipe() function fails, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the pipe() function fails, errno may be set to one of the following values: The filedes parameter is an invalid address. A read() or a write() on a pipe is interrupted by a signal and no bytes have been transferred through the pipe. More than OPEN_MAX-2 file descriptors are already opened by this process. [Tru64 UNIX] More than getdtablesize(2) file descriptors are already opened by this process. The system file table is full, or the device containing pipes has no free i-nodes. [Tru64 UNIX] The system was unable to allocate kernel memory for more file descrip- tors. RELATED INFORMATION
Commands: sh(1) Functions: fcntl(2), getmsg(2), poll(2), putmsg(2), read(2), select(2), write(2), getdtablesize(2) Standards: standards(5) delim off pipe(2)
All times are GMT -4. The time now is 08:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy