Date: Fri, 31 Jul 1998 12:53:12 -0600 (MDT) From: chanders@timing.com (Craig Anderson) To: freebsd-hackers@FreeBSD.ORG Subject: Using FreeBSD for data acquisition? (long) Message-ID: <199807311853.MAA04187@count.timing.com>
next in thread | raw e-mail | index | archive | help
My company is considering using FreeBSD for a data acquisition application. We want to know if an upper bound be placed on the latency of an application reading data from a data acquisition board? FreeBSD is being considered first and then commercial RTOS's will be tried. A test project is being done. The project uses an ISA data acquisition board. The board interrupts 500 times a second, an 8 byte data block is read from the board on each interrupt. There is a driver lkm for the board: a) driver buffers 4k data blocks. b) driver interrupt function reads 1 data block, stores data block in buffer, wakes the reader. c) driver read function waits for at least 1 data block, returns minimum of requested data blocks and available data blocks. A test application: a) Loops forever requesting 4096 data blocks. b) Saves the number of data blocks returned on each read to a file. Because the interrupts/data blocks arrive at 500 HZ, I am interpreting the number of data blocks returned on a read as a measure of read latency of the application. If the read returns 50 data blocks, it has been .1 second since the last read. (50/500 = .1) Below are code fragments from the test application. The rtprio() call is to put the process into RTP_PRIO_REALTIME. Should this make a difference? Is the code correct? At the end of the message is histogram data for a test run of about 15 hours. I plot the data with gnuplot, using a logscale for y. Note that the longest read is 480 (480/500 = .960 seconds). Note that the most common read is 50 (50/500 = .100 seconds). I'd like comments from FreeBSD hackers out there. Can an upper bound be put on the read latency? An upper bound of about .100 seconds is probably acceptable. Why is a read latency of .100 seconds (50 data blocks) so common? Should RTP_PRIO_REALTIME help? Does FreeBSD 3 have realtime features that will help? Is there a problem with the code or a better approach? Thanks in advance for any comments. Code from test application -------------------------- rtp.type = RTP_PRIO_REALTIME; rtp.prio = 0; istat = rtprio (RTP_SET, 0, &rtp); ... fd = open (DEV_PATH, O_RDONLY, 0); ... istat = ioctl(fd,GT401_START_EVENTS,&arg_ioctl); ... for (;;) { istat = read (fd,(void *)&(ttag_buf[0]),read_req); read_data_count = istat / sizeof(gt401_read); printf ("%d\n",read_data_count); fflush(stdout); } /* for (;;) */ Histogram: number of data blocks returned on a read --------------------------------------------------- col1=number of data blocks returned by a read col2=number of reads that returned this many data blocks # 1 compute bound, slow interrupt # Thu Jul 30 17:47:58 MDT 1998 # period=0.002000 freq=500.000000 RTPRIO # max count=480 total count=28303071 1.000000 134048 2.000000 27911 3.000000 4324 4.000000 2003 5.000000 5564 6.000000 4066 7.000000 3911 8.000000 2695 9.000000 2714 10.000000 5091 11.000000 2536 12.000000 2016 13.000000 298 14.000000 657 15.000000 3808 16.000000 1651 17.000000 1489 18.000000 62 19.000000 7897 20.000000 49226 21.000000 1406 22.000000 1432 23.000000 47 24.000000 404 25.000000 3190 26.000000 1537 27.000000 1346 28.000000 64 29.000000 5054 30.000000 51876 31.000000 1413 32.000000 1254 33.000000 50 34.000000 327 35.000000 2890 36.000000 1454 37.000000 1230 38.000000 44 39.000000 367 40.000000 2960 41.000000 1469 42.000000 1312 43.000000 29 44.000000 397 45.000000 2821 46.000000 1570 47.000000 1123 48.000000 184 49.000000 55950 50.000000 412800 51.000000 5 52.000000 6 53.000000 0 54.000000 2 55.000000 1 56.000000 0 57.000000 0 58.000000 2 59.000000 0 60.000000 1 61.000000 3 62.000000 2 63.000000 6 64.000000 4 65.000000 8 66.000000 19 67.000000 22 68.000000 26 69.000000 29 70.000000 8 71.000000 0 72.000000 1 73.000000 0 74.000000 1 75.000000 0 76.000000 1 77.000000 0 78.000000 1 79.000000 2 80.000000 18 81.000000 12 82.000000 25 83.000000 23 84.000000 0 85.000000 1 86.000000 0 87.000000 0 88.000000 0 89.000000 1 90.000000 0 91.000000 0 92.000000 0 93.000000 0 94.000000 0 95.000000 2 96.000000 2 97.000000 2 98.000000 0 99.000000 0 100.000000 6 101.000000 1 102.000000 0 103.000000 0 104.000000 1 105.000000 1 106.000000 1 107.000000 0 108.000000 0 109.000000 1 110.000000 0 111.000000 0 112.000000 0 113.000000 4 114.000000 5 115.000000 7 116.000000 16 117.000000 24 118.000000 28 119.000000 26 120.000000 11 121.000000 0 122.000000 0 123.000000 0 124.000000 0 125.000000 0 126.000000 0 127.000000 0 128.000000 1 129.000000 3 130.000000 14 131.000000 17 132.000000 23 133.000000 13 134.000000 0 135.000000 0 136.000000 1 137.000000 1 138.000000 0 139.000000 0 140.000000 0 141.000000 0 142.000000 3 143.000000 1 144.000000 5 145.000000 1 146.000000 0 147.000000 1 148.000000 0 149.000000 2 150.000000 4 151.000000 0 152.000000 5 153.000000 0 154.000000 0 155.000000 2 156.000000 0 157.000000 1 158.000000 1 159.000000 0 160.000000 0 161.000000 0 162.000000 0 163.000000 5 164.000000 9 165.000000 6 166.000000 9 167.000000 21 168.000000 12 169.000000 20 170.000000 10 171.000000 0 172.000000 0 173.000000 0 174.000000 0 175.000000 0 176.000000 0 177.000000 1 178.000000 0 179.000000 1 180.000000 12 181.000000 19 182.000000 13 183.000000 16 184.000000 0 185.000000 0 186.000000 1 187.000000 0 188.000000 0 189.000000 0 190.000000 0 191.000000 0 192.000000 0 193.000000 0 194.000000 0 195.000000 0 196.000000 0 197.000000 1 198.000000 0 199.000000 2 200.000000 5 201.000000 1 202.000000 0 203.000000 0 204.000000 0 205.000000 2 206.000000 0 207.000000 0 208.000000 0 209.000000 3 210.000000 0 211.000000 1 212.000000 1 213.000000 3 214.000000 4 215.000000 4 216.000000 9 217.000000 14 218.000000 25 219.000000 19 220.000000 10 221.000000 1 222.000000 0 223.000000 0 224.000000 0 225.000000 0 226.000000 0 227.000000 0 228.000000 0 229.000000 0 230.000000 24 231.000000 26 232.000000 21 233.000000 22 234.000000 0 235.000000 0 236.000000 0 237.000000 1 238.000000 1 239.000000 1 240.000000 0 241.000000 0 242.000000 0 243.000000 0 244.000000 0 245.000000 3 246.000000 0 247.000000 0 248.000000 0 249.000000 1 250.000000 3 251.000000 0 252.000000 0 253.000000 0 254.000000 1 255.000000 0 256.000000 0 257.000000 0 258.000000 0 259.000000 0 260.000000 0 261.000000 2 262.000000 1 263.000000 4 264.000000 6 265.000000 1 266.000000 10 267.000000 23 268.000000 11 269.000000 25 270.000000 10 271.000000 0 272.000000 0 273.000000 0 274.000000 0 275.000000 0 276.000000 0 277.000000 1 278.000000 0 279.000000 0 280.000000 27 281.000000 23 282.000000 21 283.000000 19 284.000000 0 285.000000 0 286.000000 0 287.000000 0 288.000000 0 289.000000 0 290.000000 0 291.000000 0 292.000000 0 293.000000 0 294.000000 0 295.000000 3 296.000000 0 297.000000 2 298.000000 1 299.000000 1 300.000000 1 301.000000 0 302.000000 0 303.000000 0 304.000000 2 305.000000 2 306.000000 0 307.000000 0 308.000000 0 309.000000 0 310.000000 0 311.000000 1 312.000000 1 313.000000 2 314.000000 1 315.000000 5 316.000000 6 317.000000 9 318.000000 19 319.000000 12 320.000000 7 321.000000 0 322.000000 0 323.000000 0 324.000000 0 325.000000 0 326.000000 0 327.000000 0 328.000000 0 329.000000 0 330.000000 19 331.000000 25 332.000000 37 333.000000 25 334.000000 0 335.000000 0 336.000000 0 337.000000 0 338.000000 0 339.000000 0 340.000000 0 341.000000 0 342.000000 0 343.000000 0 344.000000 0 345.000000 1 346.000000 0 347.000000 1 348.000000 0 349.000000 0 350.000000 1 351.000000 0 352.000000 0 353.000000 2 354.000000 2 355.000000 1 356.000000 0 357.000000 0 358.000000 0 359.000000 0 360.000000 0 361.000000 0 362.000000 0 363.000000 1 364.000000 1 365.000000 4 366.000000 6 367.000000 24 368.000000 21 369.000000 11 370.000000 11 371.000000 0 372.000000 0 373.000000 0 374.000000 0 375.000000 0 376.000000 0 377.000000 0 378.000000 0 379.000000 0 380.000000 33 381.000000 33 382.000000 30 383.000000 24 384.000000 1 385.000000 0 386.000000 0 387.000000 0 388.000000 0 389.000000 0 390.000000 0 391.000000 0 392.000000 0 393.000000 0 394.000000 0 395.000000 1 396.000000 0 397.000000 0 398.000000 0 399.000000 0 400.000000 0 401.000000 0 402.000000 0 403.000000 0 404.000000 1 405.000000 1 406.000000 0 407.000000 0 408.000000 0 409.000000 1 410.000000 0 411.000000 0 412.000000 0 413.000000 1 414.000000 0 415.000000 1 416.000000 1 417.000000 19 418.000000 13 419.000000 15 420.000000 34 421.000000 0 422.000000 0 423.000000 0 424.000000 0 425.000000 0 426.000000 1 427.000000 0 428.000000 0 429.000000 0 430.000000 55 431.000000 19 432.000000 21 433.000000 22 434.000000 0 435.000000 0 436.000000 0 437.000000 3 438.000000 0 439.000000 0 440.000000 0 441.000000 0 442.000000 1 443.000000 0 444.000000 0 445.000000 1 446.000000 0 447.000000 0 448.000000 0 449.000000 0 450.000000 82 451.000000 0 452.000000 1 453.000000 0 454.000000 0 455.000000 0 456.000000 0 457.000000 0 458.000000 0 459.000000 0 460.000000 0 461.000000 0 462.000000 0 463.000000 0 464.000000 0 465.000000 0 466.000000 0 467.000000 2 468.000000 0 469.000000 1 470.000000 34 471.000000 1 472.000000 0 473.000000 0 474.000000 0 475.000000 1 476.000000 0 477.000000 0 478.000000 0 479.000000 0 480.000000 31 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199807311853.MAA04187>