Re: A question of writing file in rtlinux, thanks
WuXin <[email protected]> Tue, 25 Jan 2005 11:44:12 +0800 (CST)
| Newsgroups | gmane.linux.real-time.rtlinux.general |
|---|---|
| Message-ID | <[email protected]> |
Such are our discussion about kernel side writing file, I repost it to mailing list. Hope everybody can profit from it, :) Any suggestion else will be welcome too. Thanks to Alejandro Lucero. I've got what u mean. That is acquiring and writing asynchronously. --- [email protected] 的正文: > On Sunday 23 January 2005 16:10, you wrote: > > First thanks very very much for your kind help~ :) > > You're welcome. > > > --- [email protected] 的正文: > > > > > On Saturday 22 January 2005 17:32, WuXin wrote: > > > > Dear Everybody: > > > > Nice to meet u in the web! > > > > Now I'm using rtlinux/free v3.1 and I > want > > > > > > to > > > > > > > write some data to a file once per 5 ms. I'm > > > > > > little > > > > > > > confused whether I can only use rtlinux's > > > > > > fifo/mbuff > > > > > > > or I can use some normal kernel function such > as > > > > "filp_open" or kernel side system call such as > > > > "open/write"? > > > > > > You can use these functions but at your own > risk, > > > since you enter in the Linux > > > kernel behaviour "no real time" world. You can > use > > > two threads, one acquiring > > > the data and writing it to a share buffer, and > other > > > writting data from the > > > shared buffer to disk using the linux kernel > > > functions. The last should be > > > less priority. If the system load (linux) is not > > > very high, this approach > > > will work, but you must decide the size of the > > > shared buffer to avoid losing > > > data. > > > > What do u mean here? The thread acquiring data is > > RTLinux thread, but what's the other thread? In my > > opinion, it's also RTLinux thread. Then we'll meet > the > > same question, how can use normal linux kernel > > functions in RTLinux thread? > > Both are rtlinux threads. The division is due to > when linux kernel functions > are used the delay can be so high that your 5ms > requirements could be > overpassed. With this approach you makes sure one > thread will always be ready > to acquire data. The other can be blocked by Linux > kernel, but this is not a > problem because: > > 1) you use a shared buffer, so writer (in the > buffer) thread can still works > 2) the reader (from the buffer, but writer to disk) > thread can make writes > calls of large sizes. > > In this way, meanwhile one thread writes B bytes to > the shared buffer 200 > times by second, the other can read from the buffer > B*10 bytes in each loop, > then saving 10 write system calls. > > About how you can use this Linux kernel functions, > you must do some tricky > things, since you are using system calls from kernel > inside. This is not > hard, and you can learn it fast. I worked with some > similar in a old project, > and I learned from khttp, the http server which runs > inside of the kernel. > You can see that in older linux kernel sources . > > > > > Btw: My method now is > > RTLinux thread acquires data and writes them into > a > > size-precounted mbuff. When the acquiring job is > over, > > i execute a user side program, read data from > mbuff > > and write to file with user-side functions such as > > "fopen" "fprintf". > > > > It works, but not direct and not perfect i think. > :) > > It depends of how many bytes you want to acquire. If > you have enough memory > this is a god approach and simple. > > > > By other hand, there are two things you can do: > > > > > > - First, Hofrat did what you want to do and he > can > > > give some detailed > > > explanations. You can see the ArvidStaub paper > in > > > the last Real Time Linux > > > Workshop too. > > > > Plz forgive my basic of How can I contact Mr. > Hofrat? > > Hofrat is the rtlinux mailing list maintainer, so I > guess he will answer you > soon. > > > Arvid Staub's "RAT -- Real-Time Audio Tools" is > > downloading and also your paper "IDE Driver and > RTLFS > > file system for RTLinux ". > > > > Keep learning from you! :) > > Really help me a lot, deeply moved. > > I hope you can go forward. If you decide to use my > code, please inform me > about your problems/goals. > > > Another question: I'm the first time using mailing > > list, so should I still post this reply to "rtl > list" > > rather than to you only? > > well, I've seen that I answered you directly. I did > wrongly. It's better to > use the mailing list. Others can profit from it. > > > > - I worked in using IDE disks from RT tasks. In > > > this way you avoid the Linux > > > impact (at least it is minimized). You can work > > > writting directly into the > > > disk, or using the rtlfs file system (designed > to > > > benefit real time tasks). > > > The drawback with this approach is you need a > > > specific disk partition to work > > > with. See www.lutherfs.com > > > > > > > Very appreciate for your reply. > Thanks a > > > > > > lot. > > > > > > > Yours > > > > Ardon > > > > > > _______________________________________________ > > > > Rtl mailing list > > > > [email protected] > > > > http://www2.fsmlabs.com/mailman/listinfo/rtl > > > > > > -- > > > Alejandro Lucero > > > OS3, OS Serveis i Solucions > > > www.os3sl.com > > > Ingeniería Informática > > > +34 665687168 > > > Av.Benjamin Franklin > > > CEEI. Parque Tecnológico de Paterna > > > Valencia(Spain) > > > > > > _________________________________________________________ Do You Yahoo!? 150万曲MP3疯狂搜,带您闯入音乐殿堂 http://music.yisou.com/ 美女明星应有尽有,搜遍美图、艳图和酷图 http://image.yisou.com 1G就是1000兆,雅虎电邮自助扩容! http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/ _______________________________________________ Rtl mailing list [email protected] http://www2.fsmlabs.com/mailman/listinfo/rtl