In my limited experience with this area, I have had moderate success using tc to set up 'Qdiscs' (Queuing Disciplines) which can accomplish what you want to do. A warning though: easy-to-use documentation or tutorials seems pretty scarce, so it probably will take you a fair bit of fiddling around if you choose to try doing this.
I configured mine using the HTB method (Hiararchical Token Bucket). It isn't perfect; I am still kinda fiddling with it on and off, but it does seem to help us share a really slooooow 28.8K dialup connection here if we are both browsing or downloading at the same time, though as you can imagine, dividing 28.8K between 2 or 3 machines is almost futile
There are kernel configurations you will need to configure when building your kernel, in the Netfilter and/or similar kernel config areas, for HTB and a large selection of other Queuing Disciplines and associated things for doing traffic-prioritizing.
Definitely use Google. Look up 'Linux Qdiscs' and similar. Also read the tc man page.
Surely there are (many?) other methods, hopefully easier or more well-documented, of doing what you want. But I don't know what they are. Maybe someone else can offer another suggestion.