From owner-freebsd-hackers Thu Sep 30 9:51:46 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from etinc.com (et-gw.etinc.com [207.252.1.2]) by hub.freebsd.org (Postfix) with ESMTP id 3C460158B9 for ; Thu, 30 Sep 1999 09:51:37 -0700 (PDT) (envelope-from dennis@etinc.com) Received: from dbsys (dbsys.etinc.com [207.252.1.18]) by etinc.com (8.9.3/8.9.3) with SMTP id MAA12186; Thu, 30 Sep 1999 12:48:34 -0400 (EDT) Message-Id: <199909301648.MAA12186@etinc.com> X-Sender: dennis@etinc.com (Unverified) X-Mailer: QUALCOMM Windows Eudora Pro Version 4.0 Date: Thu, 30 Sep 1999 11:46:30 -0400 To: W Gerald Hicks From: Dennis Subject: Re: A bug in the sppp driver? Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: <199909300954.FAA02650@bellsouth.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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