Depending upon the time period and wealth of the lord of the castle, knights and soldiers could live within a barracks, where they were crammed together, sometimes with beds/cots but often sleeping...
it was a tall long building with lots of rooms one of the rooms is called the great hall. jobs in the castle knight baker entertainer servant priest fierier blacksmith and lots more