A home Internet gateway is the node that resides between a public network and a home network for computers to share Internet connections. To insert customized queuing and scheduling codes into the embedded Linux kernel is a way to make the Linux-based home Internet gateways support Quality of Service(QoS). It is desirable that the small Linux kernel adopts an efficient queuing and scheduling algorithm to support link sharing, priority and traffic shaping. The algorithm presented in this paper is based on the concept of hierarchical link-sharing and each class in the hierarchy is bound with a token bucket, which can shape the traffic of this class. The analysis and simulation results presented in the paper show that through the novel way of weighted fair token sharing, this proposed algorithm guarantees basic bandwidth service for each class and enables weighted fair sharing of excess bandwidth, with which home computers connected to the network share the Internet service evenly.