Date: Thu, 30 Sep 1999 11:46:30 -0400 From: Dennis <dennis@etinc.com> To: W Gerald Hicks <wghicks@bellsouth.net> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: A bug in the sppp driver? Message-ID: <199909301648.MAA12186@etinc.com> In-Reply-To: <199909300954.FAA02650@bellsouth.net> References: <Your message of "Wed, 29 Sep 1999 17:25:15 BST." <038d01bf0a97$3652f8d0$2e00a8c0@nt46daniel>
next in thread | previous in thread | raw e-mail | index | archive | help
At 05:54 AM 9/30/99 -0400, W Gerald Hicks wrote: > >> doing state machines with switch statements is a big mess. > >Still, you'll find a lot of them around. Do you have a favored >technique for coding complex state machines? (I'm a collector :) yes, state tables. Clean and easy to modify. > >One scheme I've been using for quite some time is to use a function >pointer as a 'state variable', sometimes making a stack of them for >a more flexible machine. > >Sometimes I use a transition matrix for selection of the 'state function' >but more often the functions themselves perform 'next state' selection. then your back to switch statements, because you have actions that are used in multiple states. event=decode_event(cur_state,pdata); do_action(cur_state[event][action]); new_state=cur_state[event][newstate]; Dennis 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?199909301648.MAA12186>