Re: finite state machine/automaton framework?

看板DFBSD_kernel作者時間21年前 (2004/09/04 02:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串5/8 (看更多)
On Fri, 3 Sep 2004 20:05:08 +0200 "Simon 'corecode' Schubert" <corecode@fs.ei.tum.de> wrote: > for example: > > state_idle: > if: > written_byte & WHATEVER_BITMASK > newstate: > state_program_oneshot > output: > this_var = that_var; > run_foo(); static void (*state)(void); static void state_idle(void) { if (written_byte & WHATEVER_BITMASK) { this_var = that_var; run_foo(); state = state_program_oneshot; return; } else if ... } .... void run_fsm(void) { state = start_state; while (state != NULL) { state(); } } This design pattern is heavily employed in the installer. I don't think the specialized notation has many advantages over the C version, especially in this instance. Yacc and lex are a different area of application - they transform a regular expression or a grammar into a DFA or a LALR table - i.e. something of significantly different structure. On the other hand, these state descriptions look very very similar to their C equivalents. -Chris
文章代碼(AID): #11EBYf00 (DFBSD_kernel)
討論串 (同標題文章)
文章代碼(AID): #11EBYf00 (DFBSD_kernel)