Mayor Marion Barry has set a six-month deadline for determining the right size and location for a new prison facility in the District and will create a commission to make recommendations by then, a top District official said yesterday.

Hallem Williams Jr., an official in the city administrator's office who is in charge of the prison project, said yesterday the commission will be created by mayoral order.

It is to be appointed jointly by the mayor and the City Council and will include criminal justice experts and members of the community, Williams said.

Barry is counting on getting federal funding to build the prison, and Sen. Arlen Specter (R-Pa.), chairman of the Senate appropriations subcommittee on the District, has indicated in the past that money could be added to the District's budget for the project.

Specter yesterday applauded the mayor's plan to create the commission but said he thought the site selection could be done sooner than six months. "I would like to see the time shortened somewhat," he said.

Barry for some time had resisted strong pressure from Specter and law enforcement officials to build a prison to help relieve serious overcrowding at the city's Lorton Reformatory and the D.C. Jail.

The mayor had said he first wanted to look at alternative sentences to incarceration rather than build more prison space in expectation of a hefty rise in convictions and prison sentences.

But earlier this year, Barry reversed himself and said a new prison was needed and that it should be built in the District, on federal land with federal funds.

Setting a timetable himself and planning a commission on the controversial prison issue "probably reflects that he the mayor wants to get out front on it, get it done and done quickly," said one analyst close to the issue.

The new commission first would look at what type of prison is needed, what security level and what size, and then would find a site for that kind of institution, Williams said.

The city first will have to analyze what the prison population will look like over time, he said.

In the meantime, congressional hearings are to start this month on the District's budget, which each year must be approved by Congress.

The House plans to begin its work first, and Senate action is expected to take place over the summer.

City officials estimate that building a new prison would cost between $28,000 and $50,000 per cell, depending on the size and the security level.

Congress could start by putting in design money first if it wanted to spread the cost over more than one year.

Asked if he was committed to putting money for the prison in this year's budget, Specter said he is "committed to working with" Barry on funding.

U.S. Attorney Joseph E. diGenova said at a hearing in March that the Reagan administration would support federal funding for a new prison in the District.

The city's current capacity is for 3,903 prisoners at Lorton, including 400 beds at a newly opened minimum-security facility, and 1,378 at the D.C. Jail in Southeast for a total of 5,281.

The prison population at Lorton yesterday was 3,786, under its rated capacity, but was 2,558 at the D.C. Jail, more than 1,000 over capacity, according to D.C. Department of Corrections figures.

The city is under a federal court order that bars overcrowding at the jail.

Barry has argued in the past that he would prefer to work on crime prevention and alternative sentences for nonviolent crimes.

Law enforcement officials have argued that the prison population is due to rise dramatically and that room to house them is needed.