Synchronous vs asynchronous

Post a reply

Confirmation code
Enter the code exactly as it appears. All letters are case insensitive.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: Synchronous vs asynchronous

Re: Synchronous vs asynchronous

Post by andylgh »

i only want to test the stream function,not the speed

Re: Synchronous vs asynchronous

Post by support »

Hello,

You're actually asking a question on how Python handles I/O, so this isn't the right place.

As a side note -- in most cases where people have tried to test loopbacks with a single-thread program with a write followed by a read etc. it somehow failed because it got stuck in either of the two. I warmly recommend writing one program to write the data and another to read. Saves a lot of headache.

Also, in case you're heading towards making a bandwidth test soon, I suggest taking a look on this page:

http://xillybus.com/doc/bandwidth-guidelines

In particular, it begins with explaining why a bandwidth test shouldn't be done with a loopback.

Regards,
Eli

Re: Synchronous vs asynchronous

Post by andylgh »

# coding: cp936
if __name__ == '__main__':


test_dat = bytearray()
for i in range(0,2048):
test_dat.append(i%256)
print(len(test_dat))


with open(r'\\.\xillybus_write_32','wb',buffering=-1) as wfd:
with open(r'\\.\xillybus_read_32','rb',buffering=-1) as rfd:
with open(r'test.bin','wb',buffering=-1) as fd:

#write file
w_num = wfd.write(test_dat)
wfd.flush()
print('w_num = %0d'%(w_num))

#read file
rdata = rfd.read(2048)
print(len(rdata))

w_num = fd.write(rdata)
fd.flush()

the bundle demo k7,there are 2KB fifo in FPGA write32 and read32 are loopback。the example above i first write 2KB to fpga_fifo and then read 2KB ,the test is success
now i change : rdata = rfd.read(2048) -》 rdata = rfd.read(2048 + 4) , the test is block at read()
According to my understanding, it should be able to return to 2048. It should not be blocked ?

Re: Synchronous vs asynchronous

Post by support »

Hello,

Please refer to section 2 of the Xillybus host application programming guide for Windows, for an explanation on synchronous vs. asynchronous streams. It has nothing to do with blocking vs. non-blocking calls to _write() or _read().

http://xillybus.com/downloads/doc/xilly ... indows.pdf

I'm aware of the confusion given Microsoft's terminology for the same words, but they have several meanings in different contexts.

Regards,
Eli

Synchronous vs asynchronous

Post by andylgh »

In all demo bundles, the xillybus read * and xillybus write * streams are asynchronous.xillybus mem 8 is seekable and therefore synchronous.

is it Only at the host driver level ?

How to know the user application layer, The open file is block or non block?

For example in memwrite.c: how to know _write() function is block or non block

void allwrite(int fd, unsigned char *buf, int len) {
int sent = 0;
int rc;

while (sent < len) {
rc = _write(fd, buf + sent, len - sent);

if ((rc < 0) && (errno == EINTR))
continue;

if (rc < 0) {
perror("allwrite() failed to write");
exit(1);
}

if (rc == 0) {
fprintf(stderr, "Reached write EOF (?!)\n");
exit(1);
}

sent += rc;
}
}

Top