Short answer: you need a program called MyWi 4.0. It's a $19.99 one time charge (per device). It allows your phone to become a WiFi hotspot, or you can use a USB cable or bluetooth.
MyWi 4.0 - iPhone WiFi Tethering and iPad
In depth answer:
You'll have to jailbreak.
The age of your 3GS matters because those made Oct 2009 and older can be jailbroken and run untethered. This is preferable. 3GSs made Nov 2009 use a different bootrom which requires a tethered jailbreak. The iPad and iPhone 4's jailbreak is likewise tethered. (This is why I said it might be easier with the phone than the iPad)
Since yours is newer, everything I post from now on will be apply to both the iPhone and iPad, there's no difference.
Your jailbreak will be tethered. This means that whenever you have to reboot or turn off (or battery dies) you'll have to connect the device to your computer to turn it back on. This is less than optimal, but if you're like me, you hardly ever have to turn one off (perhaps once a month).
You'll need a program called redsn0w from
Dev-Team Blog
This will add a program called Cydia to your homescreen. Cydia is the jailbreak APP store. This is where you can purchase MyWi
The jailbreak process is always reversible by plugging your device into your computer and choosing restore.
Its not as hard as it sounds, and it opens up a lot more options for you.
I have a jailbroken iPhone 4. I would not have an iPhone if it were not for MyWi. It is the single most valuable feature (outside of the phone part) of a phone to me.
I do not have a home internet connection. I tether my iPhone to my MacBook. Also, I bought a WiFi iPad because I can tether it off my iPhone, so I don't have a monthly iPad data cost or home internet cost (8 months of no home internet paid for my iPad, BTW).
I don't know how many devices can be connected to the MyWi hotspot at once, but I've had no problem with a MacBook, an iPod Touch, a Nintendo DSi, and a desktop at the same time.
Plus, the phone is still usable while its sharing its connection.
Hope this helps.